It took me half a day to debug and find out the way to send email from PERL.
Email is the best form of debugging when it comes to PERL or PHP. But first I had to debug as to why email is NOT being sent from PERL.
So I thought the script would be useful for future developers so that they don’t have to spend that much time as I did debugging the delivery of email from PERL script.
Please find below the code snippet to send email from PERL.
[Take a special note of the use of ‘\’ before symbol ‘@’ in email address. This was the thing that I had missed out and spent hours debugging the issue.]
$mailprog = “/usr/sbin/sendmail”;
print MAIL “To: xyz\@test.com (Test Test)\n”;
print MAIL “From: xyz\@test.com (Test Test)\n”;
print MAIL “Subject: Test Email\n”;
print MAIL “Content-type: text/html\n\n”;
print MAIL “Test Email from perl”;