Hi all, I'm looking to send two different emails to two different clients. Currently, I only have the option to send one each if it meets a condition. I want one of these conditions to send two separate e-mails with different bodies and to different end users. What do you recommend I add to the code or what should I be looking into further to help figure this out? I've tried copying this section twice and tweaking it to new conditions but it doesn't send any emails out at all when I test it. Also tried different if else conditions that haven't worked for me. Thanks in advance.
$msgHTML .= "</FONT></BODY></HTML>"; my %mail; if ($product_row->{'ProductName'} eq "Company1"){ $mail{'subject'} = sprintf("Second Order Confirmation - Order Numb +er %s", $ordernum); $mail{'from'} = "Second Automatic Order Processor <orders\@mysite. +com>"; } else { $mail{'subject'} = sprintf("First Order Confirmation - Order Numbe +r %s", $ordernum); $mail{'from'} = "First Order Processor <orders\@mysite.com>"; } if ($bTestMode) { $mail{'to'} = 'myemail@address.com'; } else { my $deliveryEmail = param('reseller'); # if this is not null, deli +very will redirect to this email address if ($deliveryEmail) { $mail{'to'} = $deliveryEmail; $mail{'cc'} = 'myemail@mysite.com'; } else { $mail{'to'} = 'myemail@mysite.com,myemail@mysite.com'; } } $mail{'smtp'} = 'mail.mysite.com'; my $mimeMail; $mimeMail = MIME::Lite->new(From => $mail{'from'}, To => $mail{'to'}, Subject => $mail{'subject'}, Type => 'multipart/related', AuthUser=> 'user', AuthPass=> 'password'); my $both_parts = MIME::Lite->new( Type => "multipart/alternative", Data => $msgtxt, ); my $text_part = MIME::Lite->new( Type => "text/plain", Data => $msgtxt, ); my $html_part = MIME::Lite->new( Type => 'text/html', Data => $msgHTML); $both_parts->attach($text_part); $both_parts->attach($html_part); if ($product_row->{'ProductName'} eq "Company1"){ $mimeMail ->attach($both_parts); $mimeMail->attach( Encoding => 'base64', Type => 'image/jpeg', Path => './logo.jpg', Id => 'logo.jpg', Disposition => 'inline' ); } if ($product_row->{'ProductName'} ne "Company2"){ $mimeMail ->attach($both_parts); $mimeMail->attach( Encoding => 'base64', Type => 'image/jpeg', Path => './logo.jpg', Id => 'logo.jpg', Disposition => 'inline' ); } $mimeMail->send; print end_html; $dbh1->disconnect; $dbh2->disconnect; $dbh3->disconnect; sub uncommify { if ($_[0] eq "") { return "0"; } my $newstr = $_[0]; $newstr =~ s/,//g; return $newstr; } sub commify { if ($_[0] eq "") { return "0"; } my $text = reverse uncommify($_[0]); $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; } }

In reply to Need to send two simultaneous mails by salope

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.