#!/usr/bin/perl # # @(#)mutt-smtp-wrapper.pl1.2 05/05/01 # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar(a)zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for non-commercial use and without fee is hereby granted # provided that the above copyright notice appear in all copies and that # both the copyright notice and this permission notice and warranty # disclaimer appear in supporting documentation, and that the name of # Ali Onur Cinar not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior permission. # # # Usage: # # Please update the following parameters according to targeted SMTP server: # # Put the name of your SMTP server # $server = "mail.domain.name"; # # Put the address that will be used while sending trough this SMTP server # (you can still put whatever email you prefere in your From: line) # $from = "user\@domain.name"; # # Turn the debugging on/off (0=off, 1=on) # $debug = 0; # # SASL Authentication (if required) # #$username = ""; #$password = ""; # use Net::SMTP; # use Net::SMTP shift @ARGV; # check for recipient if ($#ARGV < 0) # email addresses { print STDERR "No recipient email provided in arguments.\n"; exit 1; } $smtp = Net::SMTP->new($server, Debug => $debug); # create SMTP connection if (!$smtp) # make sure that the { # connection attempt print STDERR # was successfull. "Cannot connect to $server.\n"; exit 1; } if (defined($username) && defined($password)) # authenticate { $smtp->auth($username, $password); } $smtp->mail($from); # set the sender foreach $to (@ARGV) # add each recipient { # to the list $smtp->to($to); } $smtp->data(); # start sending the # message body $smtp->datasend( # some advertisement "Received: from Mutt by mutt-smtp-wrapper.pl 1.2 " ." (www.zdo.com/articles/mutt-smtp-wrapper.shtml)\n" ); while () # send each line of { # message body last if m/^\.$/g; $smtp->datasend($_); } $smtp->dataend(); # terminate the $smtp->quit; # process _END_