On 07/08/2017 02:58 AM, timo wrote:
@ToddAndMargo <https://github.com/toddandmargo> here's how to create an
email with attachments:
|my $image = "P5\n64 64\n255\n".encode("utf8") ~ Buf[int8].new( do for
-32..^32 X -32..^32 -> ($x, $y) { 255 - (sqrt($x ** 2 + $y ** 2) * 4 %
255).ceiling }); my $email = Email::MIME.create( header-str => [from =>
"toddandma...@zoho.com", to => "redacted", subject => "Check out
my fantastic attachment!"], parts => [ Email::MIME.create( header => [
content-transfer-encoding => "quoted-printable" ], attributes => [
content-type => "text/plain", charset => "utf8" ], body-str => "Hello
Todd, check out this räd attachment!") ,Email::MIME.create( header => [
"Content-Transfer-Encoding" => "base64" ], attributes => [ content-type
=> "image/x-portable-greymap", disposition => "attachment" ], body =>
$image ) ]); say $email.as-string; |
it has a plain text body (including an utf8 character that gets encoded
with quoted-printable) and it has an image attachment (a portable
greymap that is created as a Buf, to simulate any attachments you would
slurp as binary rather than encoded as a string).
It has the to and from headers in the Email::MIME object and it is part
of the resulting text, so you can just feed that Net::SMTP's send method
that only takes the message.
This relies on retupmoca/p6-Email-MIME#5
<https://github.com/retupmoca/p6-Email-MIME/pull/5> getting merged first.
Hi Timo,
I don't understand. How do you sent this to Net::SMTP?
Where is the SMTP server's address and user name? In
Net::SMTP by chance?
I have successfully used Net::SMTP before, but I don't get what you
are saying.
I am confused. :'(
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~