Switching over to Net::SMTP::SSL from MIME::Lite has been slightly problematic. The issue I am now facing is that when using MIME::Lite I was able to easily send HTML in the body but now with NET:SMTP it is failing when it comes to adding the html to the body of the message

sub sendMail{ my $receiver = shift; my $body = shift; my $subject = "Sociabull Weekly"; print "Sending to $receiver\n"; $smtp->mail($connect{sender}); $smtp->recipient($receiver); $smtp->data() or die "Failed to send! - Data initialize : $!\n"; $smtp->datasend("To: <$receiver> \n") or die "Failed to send! -- T +o : $!\n"; $smtp->datasend("From: $connect{sender_name} <$connect{sender}> \n +") or die "Failed to send! -- From : $!\n"; $smtp->datasend("Content-Type: text/html \n") or die "Failed to se +nd! -- Content-Type : $!\n"; $smtp->datasend("Subject: $subject\n") or die "Failed to send! - S +ubject : $!\n"; $smtp->datasend("\n") or die "Failed to send! - Line Break : $!\n" +; $smtp->datasend($body) or die "Failed to send! - Body : $!\n"; $smtp->datasend("\n") or die "Failed to send! - After Body Break : + $!\n"; $smtp->dataend() or die "Failed to send! - Data End : $!\n"; }

If I print out the contents of the variable $body the html is definitely there but when it gets to the "$smtp->datasend($body) or die "Failed to send! - Body : $!\n";" line, it fails. It looks like I have the Content type set properly so once again I am asking for your expertise.

Thanks again, as always

In reply to Net::SMTP::SSL - sending HTML by edimusrex

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.