Aahhh I got it! When building up the original email, I was doing:
my $msg = MIME::Lite->new( From => $from, To => $to, Type => 'multipart/alternative', Subject => $subject_val, );


But obviously Net::SMTP does the to/from part itself. Removing it so I just had:

my $msg = MIME::Lite->new( Type => 'multipart/alternative', Subject => $subject_val, );


...and it works like a charm now. Thanks goodness for that!

Now I can relax a bit for the rest of the weekend haha

Thanks to both of you :) So for anyone who may come across this post in the future, here is the code I ended up using (appologies for not making it super pretty, but I need to call it a day :))
my $msg = MIME::Lite->new( Type => 'multipart/alternative', Subject => $subject_val, ); my $att_text = MIME::Lite->new( Type => 'text', Data => "plain text version", Encoding => 'quoted-printable', ); $att_text->attr('content-type' => 'text/plain; charset=UTF-8'); $msg->attach($att_text); my $att_html = MIME::Lite->new( Type => 'text', Data => "<b>html version</b> goo", Encoding => 'quoted-printable', ); $att_html->attr('content-type' => 'text/html; charset=UTF-8'); $msg->attach($att_html); my $email = $msg->as_string(); use Net::SMTP; my $smtp = Net::SMTP->new('smtp.gmail.com', Hello => 'domain.net', Timeout => 30, Debug => 1, SSL => 1 ) || die "Error: $!"; $smtp->auth($CFG->{db_smtp_user}, $CFG->{db_smtp_pass}) or die "Co +uld not authenticate with mail.\n"; $smtp->mail('you@gmail.com'); # from addr $smtp->to('foo@bar.com'); $smtp->data(); $smtp->datasend($email); $smtp->quit();

In reply to Re^4: Send email via Gmail by ultranerds
in thread Send email via Gmail by ultranerds

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.