Package io.toro.martini
Class EmailMethods
- java.lang.Object
-
- io.toro.martini.EmailMethods
-
public final class EmailMethods extends Object
Provides one-liners for sending and reading emails.
-
-
Constructor Summary
Constructors Constructor Description EmailMethods(io.toro.martini.email.EmailClient client)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static GloopModel
readEmail(String protocol, String login, String password, String host, int port, String folder, boolean delete, boolean debug)
Read an email.static GloopModel
sendEmail(String protocol, String login, String password, String server, int port, String from, List<GloopModel> to, List<GloopModel> cc, List<GloopModel> bcc, String subject, boolean isHtml, String body, List attachments, List<GloopModel> headers)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, Object bcc, String subject)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, Object bcc, String subject, List<javax.activation.DataSource> attachments)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, String subject)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, String subject, List<javax.activation.DataSource> attachments)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, String subject)
Send an email.static String
sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, String subject, List<javax.activation.DataSource> attachments)
Send an email.
-
-
-
Constructor Detail
-
EmailMethods
@Autowired public EmailMethods(io.toro.martini.email.EmailClient client)
-
-
Method Detail
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, String subject)
Send an email.
Example usage:
String body = 'Body of the email.' body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', 'Subject' )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)subject
- email subject- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, String subject, List<javax.activation.DataSource> attachments)
Send an email.
Example usage:
String body = 'Body of the email.' def attachments = ... body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', 'Subject', attachments )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)subject
- email subjectattachments
- optional list of email attachments- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, String subject)
Send an email.
Example usage:
String body = 'Body of the email.' body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', [ 'cc1@gmail.com', 'cc2@gmail.com' ], 'Subject' )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)cc
- CC address (can beString
,String[]
, orCollection<String>
)subject
- email subject- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, String subject, List<javax.activation.DataSource> attachments)
Send an email.
Example usage:
String body = 'Body of the email.' def attachments = ... body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', [ 'cc1@gmail.com', 'cc2@gmail.com' ], 'Subject', attachments )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)cc
- CC address (can beString
,String[]
, orCollection<String>
)subject
- email subjectattachments
- optional list of email attachments- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, Object bcc, String subject)
Send an email.
Example usage:
String body = 'Body of the email.' body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', [ 'cc1@gmail.com', 'cc2@gmail.com' ], [ 'bcc1@gmail.com', 'bcc2@gmail.com' ], 'Subject' )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)cc
- optional CC address (can beString
,String[]
, orCollection<String>
)bcc
- optional BCC address (can beString
,String[]
, orCollection<String>
)subject
- email subject- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
public static String sendEmail(String body, String protocol, String login, String password, String server, int port, String from, Object to, Object cc, Object bcc, String subject, List<javax.activation.DataSource> attachments)
Send an email.
Example usage:
String body = 'Body of the email.' def attachments = ... body.sendEmail( 'smtp', 'user@gmail.com', 'password', 'smtp.gmail.com', 587, 'from@gmail.com', 'to@gmail.com', [ 'cc1@gmail.com', 'cc2@gmail.com' ], null, 'Subject', attachments )
- Parameters:
body
- the body of the emailprotocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to address (can beString
,String[]
, orCollection<String>
)cc
- optional CC address (can beString
,String[]
, orCollection<String>
)bcc
- optional BCC address (can beString
,String[]
, orCollection<String>
)subject
- email subjectattachments
- optional list of email attachments- Returns:
- the body of the email (for chaining)
- Since:
- 1.0
-
sendEmail
@GloopObjectParameter("mailMetadata{\n mailMetadata#io.toro.martini.email.MailMetadata{\n }\n}") public static GloopModel sendEmail(@GloopParameter(choices={"smtp","smtps"},allowNull=false,allowOtherValues=true) String protocol, String login, String password, @GloopParameter(choices={"smtp.gmail.com","smtp.mail.yahoo.com","smtp-mail.outlook.com"},allowOtherValues=true,allowNull=false) String server, @GloopParameter(choices={"25","465","587"},allowOtherValues=true) int port, @GloopParameter(allowNull=false) String from, @GloopObjectParameter("to#io.toro.martini.email.Address[]{\n}") List<GloopModel> to, @GloopObjectParameter("cc#io.toro.martini.email.Address[]{\n}") List<GloopModel> cc, @GloopObjectParameter("bcc#io.toro.martini.email.Address[]{\n}") List<GloopModel> bcc, @GloopParameter(allowNull=false) String subject, @GloopParameter(defaultValue="false") boolean isHtml, String body, @GloopObjectParameter("attachments#io.toro.martini.email.DataSource[]{\n}") List attachments, @GloopObjectParameter("headers#io.toro.martini.email.Header[]{\n}") List<GloopModel> headers)
Send an email.
- Parameters:
protocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordserver
- email server hostnameport
- email server port numberfrom
- from addressto
- to addresscc
- optional CC addressbcc
- optional BCC addresssubject
- email subjectisHtml
- whether to apply content typetext/html
ortext/plain
for the emailbody
- the body of the emailattachments
- optional list of email attachmentsheaders
- email headers- Returns:
- email metadata
- Since:
- 1.0
-
readEmail
@GloopObjectParameter("output{\nmessages#io.toro.martini.email.Message[]{\n}\n}") public static GloopModel readEmail(@GloopParameter(choices={"imap","imaps","pop3","pop3s"},allowNull=false) String protocol, @GloopParameter(allowNull=false) String login, @GloopParameter String password, @GloopParameter(choices={"imap.gmail.com","pop.gmail.com","imap-mail.outlook.com","pop3.live.com","imap.mail.yahoo.com","pop.mail.yahoo.com"},allowNull=false,allowOtherValues=true) String host, @GloopParameter(choices={"993","995"},allowOtherValues=true) int port, @GloopParameter(choices="INBOX",allowOtherValues=true) String folder, @GloopParameter(defaultValue="false") boolean delete, @GloopParameter(defaultValue="false") boolean debug)
Read an email.
- Parameters:
protocol
- protocol of the email serverlogin
- email server loginpassword
- email server passwordhost
- email server hostnameport
- email server port numberfolder
-delete
- if email is to be deleted after readingdebug
- whether or not to print debug information to the console- Returns:
- the email message
- Since:
- 1.0
-
-