note: yes the *'s are just me removing any e-mail info here is my actually codeNet::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
#!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"; } }
In reply to Having trouble sending an e-mail with NET::SMTP by BlindMonkey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |