Saturday, May 23, 2015

Sendmail Utility: Sending mail in PERL

SendMail is a lightweight, command line SMTP email client. If you are using Linux/Unix machine then you can use sendmail utility inside your Perl program to send email.

Here you can find simple script to send an email  with using sendmail utility.

#!/usr/bin/perl
$to = 'mbcdba@gmail.com';
$from = 'no_auto_reply@google.com';
$subject = 'Sample Test Email';
$message = 'This is sample email for testing PERL script';

open(MAIL, "|/usr/sbin/sendmail -t");

# Email Header
 print MAIL "To: $to\n";
 print MAIL "From: $from\n";
 print MAIL "Subject: $subject\n\n";
# Email Body
 print MAIL $message;

 close(MAIL);
 print "Email Sent Successfully\n";

Thats it..Hope this will help you.. :)

Thanks,
Chowdari

No comments:

Post a Comment

Some Most Popular Articles