Class Mailer
java.lang.Object
com.codename1.backend.mail.Mailer
A server's mail support: its transport, its queue and its defaults.
Application code injects a MailSender, which sends through the one its
server has. This class is what Mailers.open(Config, DataSource) answers, for code that sets
one up by hand -- a command line tool, a check.
-
Method Summary
Modifier and TypeMethodDescriptionvoidForgets whatsentanswers.voidclose()Stops sending.The transport mails leave through.booleanWhether the transport could reach its server the last time it tried.intpending()Mails accepted and neither delivered nor given up on yet.voidTakesmailfor delivery and returns without waiting for it.voidTakes several mails; they leave over one connection where the transport has connections.voidSendsmailon the calling thread and returns when the server has taken it, or throws why it did not.sent()The mails sent through thememory:transport, oldest first: what a test asserts on.The name of the transport mail leaves through, such assmtp.
-
Method Details
-
getTransport
The transport mails leave through. -
send
Takes
mailfor delivery and returns without waiting for it.Inside a database transaction the mail is sent only if the transaction commits. A failure to deliver is retried and then recorded, never thrown here; what this throws is a mail that cannot be sent at all -- no sender, a template that does not exist.
- Throws:
IOException
-
send
Takes several mails; they leave over one connection where the transport has connections.- Throws:
IOException
-
sendNow
Sendsmailon the calling thread and returns when the server has taken it, or throws why it did not. No queue, no retry and no regard for a transaction: for a caller that has to know, and has the time to wait.- Throws:
IOException
-
sent
-
clearSent
public void clearSent()Forgets whatsentanswers. -
pending
public int pending()Mails accepted and neither delivered nor given up on yet. -
isHealthy
public boolean isHealthy()Whether the transport could reach its server the last time it tried. -
transportName
The name of the transport mail leaves through, such assmtp. -
close
public void close()Stops sending. Mails that are due are handed over first, for up to five seconds; with a data source the rest are sent by the next start.
-