Email::Sender::Transport::Mailgun - Mailgun transport for Email::Sender
use Email::Sender::Simple qw( sendmail ); use Email::Sender::Transport::Mailgun qw( ); my $transport = Email::Sender::Transport::Mailgun->new( api_key => '...', domain => '...', ); my $message = ...; sendmail($message, { transport => $transport });
This transport delivers mail via Mailgun's messages.mime API.
The SMTP transport can also be used to send messages through Mailgun. In this case, Mailgun options must be specified with Mailgun-specific MIME headers.
This module exposes those options as attributes, which can be set in code, or via EMAIL_SENDER_TRANSPORT_ environment variables.
EMAIL_SENDER_TRANSPORT_
This module uses Mailgun's messages.mime API, not the full-blown messages API.
If you want to use advanced Mailgun features such as templated batch mailouts or mailing lists, you're better off using something like WebService::Mailgun or WWW::Mailgun.
The attributes all correspond directly to Mailgun parameters.
Mailgun API key. See https://documentation.mailgun.com/api-intro.html#authentication
Mailgun domain. See https://documentation.mailgun.com/api-intro.html#base-url
These correspond to the o: options in the messages.mime section of https://documentation.mailgun.com/api-sending.html#sending
o:
messages.mime
Id of the campaign. Comma-separated string list or arrayref of strings.
Desired time of delivery. String or DateTime object.
Enables/disables DKIM signatures. 'yes' or 'no'.
'yes'
'no'
Tag string. Comma-separated string list or arrayref of strings.
Enables sending in test mode. 'yes' or 'no'.
Toggles tracking. 'yes' or 'no'.
Toggles clicks tracking. 'yes', 'no' or 'html_only'.
'html_only'
Toggles open tracking. 'yes' or 'no'.
The o: options above can also be specified using the X-Mailgun- headers listed here https://documentation.mailgun.com/user_manual.html#sending-via-smtp
X-Mailgun-
If a single-valued option is specified in both the options and the headers, experimentation shows the header takes precedence. This doesn't seem to be documented, so don't rely on this behaviour.
Multi-valued options use both the options and the headers.
The great strength of Email::Sender is that you don't need to hardcode your transport, nor any of the options relating to that transport. They can all be specified via environment variables.
To select the Mailgun transport, use EMAIL_SENDER_TRANSPORT=Mailgun.
EMAIL_SENDER_TRANSPORT=Mailgun
To specify any of the attributes above, prepend the attribute name with EMAIL_SENDER_TRANSPORT_.
Copyright (C) Stephen Thirlwall.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Stephen Thirlwall <sdt@cpan.org>
To install Email::Sender::Transport::Mailgun, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Email::Sender::Transport::Mailgun
CPAN shell
perl -MCPAN -e shell install Email::Sender::Transport::Mailgun
For more information on module installation, please visit the detailed CPAN module installation guide.