mkdir -p lib/Mail/Mailer/smtp #### package Mail::Mailer::smtp::From; use base Mail::Mailer::smtp; sub exec { my ($self, $exe, $args, $to) = @_; my %opt = @$args; my $host = $opt{Server} || undef; $opt{Debug} ||= 0; my $smtp = Net::SMTP->new($host, %opt) or return undef; if($opt{Auth}) { $smtp->auth(@{$opt{Auth}}) or return undef; } ${*$self}{sock} = $smtp; # # Adding a patch to set the From Address.. # $smtp->mail($self->mailaddress); $smtp->mail( $opt{From} ) if $opt{From}; # # End patch. # $smtp->to($_) for @$to; $smtp->data; untie *$self if tied *$self; tie *$self, 'Mail::Mailer::smtp::pipe', $self; $self; } 1; #### #! /usr/bin/perl use warnings; use strict; use lib './lib'; use Mail::Mailer::smtp::From; use Mail::Send; my $msg= Mail::Send->new; $msg->to('An@Address'); $msg->subject('Test Code'); my $fh = $msg->open('smtp::From', Server => 'smtp.comcast.net', Auth => [ 'user','pass' ], Port => 587, From => 'me@comcast.net', Debug => 1 ); print $fh "This is a test message.\n"; $fh->close or die("Could not send message.\n");