Send Automatic Emails to High Bidders

Send payment instructions to your customers automatically.

Here’s a simple script that will scan all your auctions that have ended in the last 24 hours and send a payment-instructions email to each high bidder:

             #!/usr/bin/perl
             require 'ebay.pl';
             
             $template = "template.txt";
             
             $today = &formatdate(time);
             $yesterday = &formatdate(time - 864000);
             my $page_number = 1;
             PAGE:
             while (1) {
                 my $rsp = call_api({ Verb => 'GetSellerList',
                                DetailLevel => 8,
                                     UserId => $user_id,
                                EndTimeFrom => $yesterday,
                                  EndTimeTo => $today,
                                 PageNumber => $page_number
                 });

                 if ($rsp->{Errors}) {
                   print_error($rsp);
                   last PAGE;
                 }
                 foreach (@{$rsp->{SellerList}{Item}}) {
                 my %i = %$_; 
                 ($id, $title, $currency, $price, $highbidder, $checkout) = 
                        @i{qw/Id Title CurrencyId CurrentPrice HighBidder Checkout/};

                 $bidder email = $highbidder->{User}{Email}; if ($bidderemail =~ "\@") { $shipping = $checkout->{Details}{ShippingHandlingCosts}; $total = $price + $shipping; open(MAIL,"|/usr/sbin/sendmail -t"); print MAIL "To: $bidderemail\n"; print MAIL "From: $selleremail\n"; print MAIL "Reply-To: $selleremail\n"; print MAIL "Subject: $title\n\n"; open (COVER, "$localdir/$template"); while ( $line = <COVER> ) { if ($line eq "<insert title here>\n") { print MAIL $title; } elsif ($line eq "<insert item here>\n") { print MAIL $id; } elsif ($line eq "<insert shipping here>\n") { print MAIL $currency . sprintf("%0.2f", $shipping); } elsif ($line eq "<insert total here>\n") { print MAIL $currency . sprintf("%0.2f", ...

Get eBay Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.