Hi Everyone, I am using MIME::Lite to establish email connection, I am doing fine with the module. The problem is to pass parameter through this subroutine, my intention is to show the value of this parameter in email subject and body. But my script does not show the value properly. Can anybody help?
&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; }

In reply to Pass parameter in email subject and body through MIME::Lite; by ytjPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.