use Net::SMTP; $mailhost = 'smtp.gmail.com'; $smtp = Net::SMTP->new($mailhost) || die "Error: $!"; print "\nWho would you like the e-mail to be from?"; $from = <STDIN>; chomp $from; print "\nWho would you like to send the e-mail to?"; $to = <STDIN>; chomp $to; print "\nWhat would you like the subject of your e-mail to be?\n"; $subj = <STDIN>; chomp $subj; print "\nWhat is your message?\n"; $message = <STDIN>; chomp $message; $smtp->mail($from); $smtp->to($to); $smtp->data(); #Start the data sending #These are the headers for the e-mail. Newline character signifies end + of headers. $smtp->datasend("From: $from\n"); $smtp->datasend("To: $to\n"); $smtp->datasend("Subject: $subj\n"); $smtp->datasend("\n"); $smtp->datasend("$message"); $smtp->dataend() || print "Dataend failed: $!"; #End the data sending $smtp->quit; #Close the smtp connection
In reply to Can't get Net::SMTP to work by Metaphysical
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |