Mail-Make
view release on metacpan or search on metacpan
MailFrom => 'bounce@example.com',
);
Assembles the message and submits it to an SMTP server via [Net::SMTP](https://metacpan.org/pod/Net%3A%3ASMTP), which is a core perl module, and loaded only when this method is called.
This takes a hash or hash reference of options.
Credential and recipient validation is performed **before** any network connection is attempted, so configuration errors are reported immediately without consuming network resources.
Recognised options:
- `AuthMechanisms`
Space-separated list of SASL mechanism names in preference order.
Defaults to `"PLAIN LOGIN"`, which are safe and universally supported over an encrypted channel (STARTTLS or SSL).
The actual mechanism used is the intersection of this list and what the server advertises. If no intersection exists, deprecated challenge-response mechanisms (`DIGEST-MD5`, `CRAM-MD5`, `GSSAPI`) are excluded and the remainder of the server's lis...
- `Debug`
Boolean. Enables [Net::SMTP](https://metacpan.org/pod/Net%3A%3ASMTP) debug output.
- `Hello`
The FQDN sent in the EHLO/HELO greeting.
- `Host`
Hostname, IP address, or an already-connected [Net::SMTP](https://metacpan.org/pod/Net%3A%3ASMTP) object. If an existing object is passed, it is used as-is and **not** quit on completion (the caller retains ownership of the connection).
If omitted, the colon-separated list in `$ENV{SMTPHOSTS}` is tried first, then `mailhost` and `localhost` in that order.
- `MailFrom`
The envelope sender address (`MAIL FROM`). Defaults to the bare addr-spec extracted from the `From:` header.
- `Password`
Password for SMTP authentication. May be:
- A plain string.
- A `CODE` reference called with no arguments at authentication time.
Useful for reading credentials from a keyring or secrets manager without storing them in memory until needed:
Password => sub { MyKeyring::get('smtp') }
- `Port`
SMTP port number. Common values:
- `25` - plain SMTP (default when `SSL` is false)
- `465` - SMTPS, direct SSL/TLS (use with `SSL => 1`)
- `587` - submission, usually STARTTLS (use with `StartTLS => 1`)
- `SSL`
Boolean. When true, the connection is wrapped in SSL/TLS from the start (SMTPS, typically port 465).
Requires [IO::Socket::SSL](https://metacpan.org/pod/IO%3A%3ASocket%3A%3ASSL).
- `StartTLS`
Boolean. When true, a plain connection is established first and then upgraded to TLS via the SMTP `STARTTLS` extension (typically port 587).
Requires [IO::Socket::SSL](https://metacpan.org/pod/IO%3A%3ASocket%3A%3ASSL). Ignored when `Host` is a pre-built [Net::SMTP](https://metacpan.org/pod/Net%3A%3ASMTP) object.
- `SSL_opts`
Hash reference of additional options passed to [IO::Socket::SSL](https://metacpan.org/pod/IO%3A%3ASocket%3A%3ASSL) during the SSL/TLS handshake. For example:
SSL_opts => { SSL_verify_mode => 0 } # disable peer cert check
SSL_opts => { SSL_ca_file => '/etc/ssl/ca.pem' }
- `Timeout`
Connection and command timeout in seconds, passed directly to [Net::SMTP](https://metacpan.org/pod/Net%3A%3ASMTP).
- `To`, `Cc`, `Bcc`
Override the RCPT TO list. Each may be a string or an array reference of addresses. When omitted, the corresponding message headers are used.
`Bcc:` is always stripped from the outgoing message headers before transmission, per RFC 2822 §3.6.3.
- `Username`
Login name for SMTP authentication (SASL). Requires [Authen::SASL](https://metacpan.org/pod/Authen%3A%3ASASL).
Must be combined with `Password`. Validated before any connection is made.
**Typical usage examples:**
# Plain SMTP, no auth (LAN relay)
$mail->smtpsend( Host => 'mail.example.com' );
# SMTPS (direct TLS, port 465)
$mail->smtpsend(
Host => 'smtp.example.com',
Port => 465,
SSL => 1,
Username => 'jack@example.com',
Password => 'secret',
);
# Submission with STARTTLS (port 587) and password callback
$mail->smtpsend(
Host => 'smtp.example.com',
Port => 587,
StartTLS => 1,
Username => 'jack@example.com',
Password => sub { MyKeyring::get('smtp_pass') },
);
Returns the list of accepted recipient addresses in list context, or a reference to that list in scalar context.
If an error occurs, it sets an [exception object](https://metacpan.org/pod/Mail%3A%3AMake%3A%3AException), and returns `undef` in scalar context, or an empty list in list context.
## use\_temp\_file( \[$bool\] )
When true, ["as\_string\_ref"](#as_string_ref) always spools to a temporary file regardless of message size. Useful when you know the message will be large, or when you want to bound peak memory use unconditionally. Default: false.
# GPG METHODS
These methods delegate to [Mail::Make::GPG](https://metacpan.org/pod/Mail%3A%3AMake%3A%3AGPG), which requires [IPC::Run](https://metacpan.org/pod/IPC%3A%3ARun) and a working `gpg` (or `gpg2`) installation. All three methods produce RFC 3156-compliant...
## gpg\_encrypt( %opts )
Encrypts this message for one or more recipients and returns a new [Mail::Make](https://metacpan.org/pod/Mail%3A%3AMake) object whose entity is an RFC 3156 `multipart/encrypted; protocol="application/pgp-encrypted"` message.
Required options:
( run in 1.618 second using v1.01-cache-2.11-cpan-39bf76dae61 )