How to send an email in Perl?

Member

by hadley , in category: Other , a year ago

How to send an email in Perl?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by jesse , a year ago

@hadley Use sendmail to send a new email using Perl code as an example:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
$to = '[email protected]';
$from = 'from@your_site.com';
$subject = 'Test email with Perl.';
$msg = 'How to send an email in Perl?';
 
open(MAIL, "|/usr/sbin/sendmail -t");
 
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL $msg;

close(MAIL);
print "Email sent\n";


Member

by davorg , a year ago

@hadley 


The answer to this question is in the Perl FAQ. How do I send email?