ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
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;
EHLO command failed: at ../test.cgi line 88.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Send email via Gmail
by hippo (Archbishop) on Oct 08, 2016 at 13:23 UTC | |
by ultranerds (Hermit) on Oct 08, 2016 at 13:37 UTC | |
by hippo (Archbishop) on Oct 08, 2016 at 14:04 UTC | |
by ultranerds (Hermit) on Oct 08, 2016 at 14:18 UTC | |
by hippo (Archbishop) on Oct 08, 2016 at 14:55 UTC | |
|
Re: Send email via Gmail
by stevieb (Canon) on Oct 08, 2016 at 14:27 UTC | |
by ultranerds (Hermit) on Oct 08, 2016 at 15:11 UTC | |
by stevieb (Canon) on Oct 08, 2016 at 15:18 UTC | |
by ultranerds (Hermit) on Oct 08, 2016 at 15:27 UTC | |
|
Re: Send email via Gmail
by RonW (Parson) on Oct 11, 2016 at 21:19 UTC |