NAME
Punk::Mailer::Result - what a delivery attempt came to
SYNOPSIS
my $r = $mailer->send(\%message);
if ($r->accepted) { log_id($r->id) }
elsif ($r->retryable) { die "try again: " . $r->message } # deferred or failed
else { give_up($r->message) } # rejected
DESCRIPTION
Delivery never throws. A refused connection, a server's 5xx, a pipe that exited, a provider's 429 - each is a Result, so the code that asked decides what to do, and a job body decides whether to retry.
There is no boolean overload, deliberately. unless ($r) means "there is no result", never "it was rejected"; ask accepted when that is the question.
STATUS
status is one word:
accepted-
The other side took responsibility for the message: SMTP
250afterDATA, a provider's2xx, a sendmail that exited0. deferred-
Temporarily refused, and worth retrying later: SMTP
4xx, a provider's429or5xx. rejected-
Refused, and a retry will be refused the same way: SMTP
5xx, a provider's other4xx, a message over a transport's limit. failed-
No verdict at all: the connection was refused or lost, the TLS handshake failed, the command could not be run. Usually worth retrying.
unsent-
The log transport: recorded, not delivered, by configuration.
METHODS
status
The word above.
accepted
deferred
rejected
failed
unsent
True when status is that word.
retryable
True for deferred and failed: the thing a job asks before it dies to be retried.
code
The SMTP reply code or the HTTP status; a sendmail exit status; undef when there was no conversation.
enhanced
The SMTP enhanced status code (5.7.1) when the server sent one, else undef.
message
What the server, provider or transport said - one line, suitable for a log.
id
The provider's id for the message, or the Message-ID the message carries for transports that have no id of their own; undef on a failure.
transport
The short name of the transport that produced this Result.
recipients
{ 'a@example.com' => { code => 250, message => 'ok' }, ... }
Per-recipient verdicts, for transports that give one (SMTP). A message some of whose recipients were refused while at least one was accepted is accepted with the refusals recorded here, which is what the server did.