Hi,

I'm having real fun trying to get emails sending through Gmails's SMTP! I'm building the email up fine using MIME::Lite:

  my $msg = MIME::Lite->new(
    From     => $from,
    To       => $to,
    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     => "html version foo",
    Encoding => 'quoted-printable',
   );
   $att_html->attr('content-type' => 'text/html; charset=UTF-8');
   $msg->attach($att_html);

   my $email = $msg->as_string();

   print "BLA: $email \n";
This creates the email exactly as I want (I'm going to to having a plain text body, html body, and attachment) How on earth do I send the email? I've tried tons of existing modules, but they either seem to break (or are 10+ years old). For example: use Net::SMTP::TLS; my $mailer = new Net::SMTP::TLS( $CFG->{db_smtp_server}, Hello => 'smtp.gmail.com', #Port => 25, #redundant User => $CFG->{db_smtp_user}, Password=> $CFG->{db_smtp_pass}); $mailer->mail($from); $mailer->to($to); $mailer->data; $mailer->datasend("Sent thru TLS!"); $mailer->dataend; $mailer->quit;

But I get an error:

EHLO command failed:
 at ../test.cgi line 88.


I can't believe how complicated / long winded this has proven to be (I've written a whole invoice generating script in the time its taken to get here :S)

TIA for any suggestions

In reply to 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.