in reply to Re^2: Need to send an email through my SMTP server using Perl
in thread Need to send an email through my SMTP server using Perl

Really you're going to find it much easier in the long wrong (espcially to manage) to just utilize Email::Sender::Simple with Email::Simple::Creator: here's an easy to understand example:
my $email = Email::Simple->create( header => [ To => $p->{email_to}, Cc => $p->{email_cc}, From => $CONF->{smtp}->{from}, Subject => $sub ], body => $str ); if($DRYRUN){ print "---- EMAIL ----\n${$email->{body}}\n---- END FO + EMAIL ----\n" if $DEBUG; } elsif($CONF->{smtp}->{enabled}) { # Do some more emailing and stuff below... my $transport; $transport = Email::Sender::Transport::SMTP->new({ host => $CONF->{smtp}->{hos +t}, port => $CONF->{smtp}->{por +t}, ssl => $CONF->{smtp}->{ssl +}, sasl_username => $CONF->{smtp}->{sas +l_username}, sasl_password => $CONF->{smtp}->{sas +l_password}, allow_partial_success => $CONF->{smtp}->{all +ow_partial_success}, helo => $CONF->{smtp}->{hel +o}, localaddress => $CONF->{smtp}->{loc +aladdress}, localport => $CONF->{smpt}->{loc +alport}, timeout => $CONF->{smpt}->{tim +eout} }); sendmail($email, { transport => $transport }); }