BlindMonkey has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to send an e-mail out with NET::SMTP. at first i was having difficulties having it connect to the server but thanks to the chatterbox users i got it connecting. i now get this from the debugging info. it looks like it works but i never recieve the e-mail. does anyone have any ideas.
Net::SMTP>>> Net::SMTP(2.29) Net::SMTP>>> Net::Cmd(2.26) Net::SMTP>>> Exporter(5.58) Net::SMTP>>> IO::Socket::INET(1.27) Net::SMTP>>> IO::Socket(1.28) Net::SMTP>>> IO::Handle(1.24) Net::SMTP=GLOB(0x1a093b0)<<< 220 mail.bellsouth.net ESMTP server (Inte +rMail vM.5.01.06.11 201-253-122-130-111-20040605) ready Wed, 4 May 20 +05 18:22:37 -0400 Net::SMTP=GLOB(0x1a093b0)>>> EHLO localhost.localdomain Net::SMTP=GLOB(0x1a093b0)<<< 250-imf17aec.mail.bellsouth.net Net::SMTP=GLOB(0x1a093b0)<<< 250-HELP Net::SMTP=GLOB(0x1a093b0)<<< 250-PIPELINING Net::SMTP=GLOB(0x1a093b0)<<< 250-DSN Net::SMTP=GLOB(0x1a093b0)<<< 250-8BITMIME Net::SMTP=GLOB(0x1a093b0)<<< 250 SIZE 26214400 Net::SMTP=GLOB(0x1a093b0)>>> MAIL FROM:<**************@gmail.com> Net::SMTP=GLOB(0x1a093b0)<<< 250 Sender <**************@gmail.com> Ok Net::SMTP=GLOB(0x1a093b0)>>> RCPT TO:<**************@hotmail.com> Net::SMTP=GLOB(0x1a093b0)<<< 250 Recipient <**************@hotmail.com +> Ok Net::SMTP=GLOB(0x1a093b0)>>> DATA Net::SMTP=GLOB(0x1a093b0)<<< 354 Ok Send data ending with <CRLF>.<CRLF +> Net::SMTP=GLOB(0x1a093b0)>>> . Net::SMTP=GLOB(0x1a093b0)<<< 250 Message received: 20050504222237.KCUR +2434.imf17aec.mail.bellsouth.net@localhost.localdomain Net::SMTP=GLOB(0x1a093b0)>>> QUIT Net::SMTP=GLOB(0x1a093b0)<<< 221 imf17aec.mail.bellsouth.net ESMTP ser +ver closing connection
note: yes the *'s are just me removing any e-mail info here is my actually code
#!perl use strict; use Net::SMTP; open STDERR, ">errlog.log" or die "Couldn't open errlog.log: $!\n"; open CONFIG, "config.ini" or die "Couldn't open config.ini: $!\n"; dbmopen(my %DATA, "mail_database", undef) or die "Cannot open database: $!\n"; chomp(my ($from, $server, $message_path) = <CONFIG>); if($from =~ /^E-MAIL:\s?(\w+(\.)?\w+\@\w+\.\w+)/){ $from = $1; } if($server =~ /^SERVER:\s?(\w+\.\w+.\w+)/){ $server = $1; } if($message_path =~ m<^MESSAGE_PATH:\s?((\.?(/|\\)?\w+)+)>){ $message_path = $1; } open MESSSAGE, "$message_path" or die "Couldn't open '$message_path': $!\n"; chomp(my @message = <MESSAGE>); my ($sec, $min, $hour, $day, $month) = localtime; $month++; my @send_to = &get_emails; foreach(@send_to){ my $smtp; $smtp = Net::SMTP->new($server, Timeout => 60, Debug => 1) or die "Couldn't connect to server '$server': $!.\n" unless $smtp; $smtp->mail($from); $smtp->to($_); $smtp->data(); foreach(@message){ $smtp->datasend($_); } $smtp->dataend(); $smtp->quit; } print "Done.\n"; sub get_emails{ my @to; foreach(keys %DATA){ if($DATA{$_} eq "$month $day"){ push(@to, $_); } } if(defined @to){ return @to; } else{ die "No e-mails found with today's date.\n"; } }

Replies are listed 'Best First'.
Re: Having trouble sending an e-mail with NET::SMTP
by mda2 (Hermit) on May 05, 2005 at 03:05 UTC
    Your code is ok... Sent mail to smtp server.

    But, gmail.com and hotmail.com uses SPF tool on SpamWAR, and any messages sent from ipīs not listed on DNS TXT records with domain sender are discarded or denied.

    After some days (default 5) you receive your messages on return...

    --
    Marco Antonio
    Rio-PM

      do you think doing somekind of authentication would work? or do i need to register or submit something?
        BlindMonkey,

        You need to use smtp server's domain on "From" field.

        $smtp->mail('***@bellsouth.net');

        --
        Marco Antonio
        Rio-PM

Re: Having trouble sending an e-mail with NET::SMTP
by sh1tn (Priest) on May 04, 2005 at 23:24 UTC
    One possible problem arise from the sender machine address - you imitate
    gmail.com, but your mashine is not really gmail.com (I suppose).
    Try to send from your own real ip address or the address of your proxy/nat machine.


      i don't know what is wrong. i tried using just the IP, i tried using the household bellsouth e-mail account. i haven't recieved any e-mails. changing it from the previous gmail e-mail to the bellsouth one seemed to make no different. just the e-mails were different in the error log. do i need to worry about authentication?
        think Perl, that's my advice. ;)
        open MAIL, "|mail -s me@sender.com" || die $!; print MAIL "some stuff"; close MAIL;


        language is a virus from outer space.