ytjPerl has asked for the wisdom of the Perl Monks concerning the following question:
&SendMail($parameter); sub SendMail() { my $service = @_; my $msgTo = 'xxx'; my $msgFrom = 'xxx'; my $smtphost = 'xxx.com'; my $smtpport = 25; my $msgSubject = '$service '; my $msg = MIME::Lite->new ( From => $msgFrom, To => $msgTo, Subject => $msgSubject, Type =>'multipart/alternative', ) or die "Error creating multipart container: $!\n"; # Create the text part my $text_part = MIME::Lite::->new( 'Type' => 'text/plain', 'Data' => 'Hi $service', ); # Create the HTML part my $html_part = MIME::Lite::->new( 'Type' => 'multipart/related', ); $html_part->attach( 'Type' => 'text/html', 'Data' => 'Hi $service', ); $msg->attach($text_part); $msg->attach($html_part); my $email = $msg->as_string(); my $smtp = Net::SMTP_auth->new($smtphost, Port=>$smtpport) or die "Can +'t connect"; #$smtp->auth('PLAIN', $smtpuser, $smtppass) or die "Can't authenticate +:".$smtp->message(); $smtp->mail($msgFrom) or die "Error:".$smtp->message(); $smtp->recipient($msgTo) or die "Error:".$smtp->message(); $smtp->data() or die "Error:".$smtp->message(); $smtp->datasend($email) or die "Error:".$smtp->message(); $smtp->dataend() or die "Error:".$smtp->message(); $smtp->quit or die "Error:".$smtp->message(); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pass parameter in email subject and body through MIME::Lite;
by Corion (Patriarch) on Sep 30, 2019 at 16:43 UTC | |
|
Re: Pass parameter in email subject and body through MIME::Lite;
by marto (Cardinal) on Sep 30, 2019 at 16:51 UTC |