Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Respected Monks,

I've been trying to use Email::Simple module and stuff works fine....but attachments don't work. Documentation does not indicate that the module has an attachment option, but I tried it anyways like so.

my $new_email = Email::Simple->create( header => [ To => 'to@email.com', From => 'from@email.com', Subject => 'Test Message.', ], body => "This is a simple test Message sent using my script.\ \nScript Location: $abs_path\ \nServer name: $ENV{'COMPUTERNAME'}\n", attachment => "README.md", );

I get the email, but not the attachment.

Replies are listed 'Best First'.
Re: Does Email::Simple have "attachment" option?
by tobyink (Canon) on Aug 30, 2020 at 20:56 UTC

      Thank you for the response, but I was looking for a way to to send multiple attachments, it that possible with Email::Stuffer?

        Yes, you just call the attach or attach_file methods multiple times.

        use Email::Stuffer; 'Email::Stuffer' ->transport('SMTP', { host => '10.0.0.123' }) ->from('alice@example.net') ->to('bob@example.org') ->subject('Test') ->text_body("This is a test.\n") ->attach_file('wait_its_all_cake.jpeg') ->attach_file('always_has_been.gif') ->send_or_die;

        Most likely, yes, if you handle all the encoding of the body parts yourself.

        Maybe now is a good moment to use MIME::Lite? Despite the claims in its documentation, it still works well and allows for attachments...