Difference between revisions of "Perl: Sendmail"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
(Created page with " #! /usr/bin/perl -w ############################################################################## # Filename: sendmail.pl # Description: Simple Send Mail S...")
(No difference)

Revision as of 15:36, 9 March 2011

  1. ! /usr/bin/perl -w
  2. Filename: sendmail.pl
  3. Description: Simple Send Mail Script
  4. Usage: perl sendmail.pl [recipients] [subject] [message]

use strict; use Mail::Sendmail;

  1. Print out usage

if ($#ARGV != 2) {

  print "Usage: send_mail addresses message\n";
  exit;

}

my $recipients = $ARGV[0]; my $subject = $ARGV[1]; my $message = $ARGV[2];

  1. Send Mail

my %mail = (

 smtp	=> "relay.cig.mot.com",
 to	=> $recipients,
 cc	=> "",
 bcc	=> "",
 from 	=> "sender\@company.com",
 subject => $subject,
 message => $message

);

sendmail(%mail);

exit;