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.
In reply to Send email via Gmail by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |