Skip to content

Instantly share code, notes, and snippets.

@Xliff
Last active August 16, 2021 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xliff/8b70f4309f3551508787e401d1cccfdd to your computer and use it in GitHub Desktop.
Save Xliff/8b70f4309f3551508787e401d1cccfdd to your computer and use it in GitHub Desktop.
Inline::Perl5 and Email::MIME

So I was working on a monitoring solution for our EC2 instances, this weekend. Of course, one of those features we had to put in was an email-notification facility. I built it out alright, but then came the email sending code.

I deciced to use Email::MIME and Email::Sender, since I don't think there are any Raku equivalents. I already had working code in Perl so I thought this would be a cinch for Inline::Perl5.

Then comes this bit:

my $email = Email::MIME.create(
  'header_str' => [
    From    => 'me@sender.com',
    To      => 'you@the.recipient.biz',
    Subject => "Drive Space Warning Triggered for 'i-deadbeef'"
  ],
  'parts', $parts
);

Did that work?

Um. No.

Email::MIME comes back with 'no recipients'!

So I puttered around with Data::Dumper and found the problem: It's better to not use the Pair syntax, here.

This is what worked:

my $email = Email::MIME.create(
  'header_str', [
    'From',    'me@sender.com',
    'To',      'you@the.recipient.biz',
    'Subject'.  "Drive Space Warning Triggered for 'i-deadbeef'"
  ],
  'parts', $parts
);

Are there cleaner solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment