本文整理汇总了Java中org.apache.commons.mail.Email.setMsg方法的典型用法代码示例。如果您正苦于以下问题:Java Email.setMsg方法的具体用法?Java Email.setMsg怎么用?Java Email.setMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.mail.Email
的用法示例。
在下文中一共展示了Email.setMsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEmail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public void sendEmail(final EmailData emailData) {
try {
Email email = new SimpleEmail();
email.setHostName(smtpServer);
email.setSmtpPort(smtpPort);
email.setAuthenticator(new DefaultAuthenticator(username, password));
email.setSSLOnConnect(secure);
email.setFrom(emailData.getAddressFrom());
email.setSubject(emailData.getSubject());
email.setMsg(emailData.getMessageContent());
email.addTo(emailData.getAddressTo());
email.send();
} catch (org.apache.commons.mail.EmailException e) {
throw new EmailException(e);
}
}
示例2: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void send(String mailAddress, String title, String content) {
if (StringUtils.isBlank(mailAddress)) {
return;
}
try {
Email email = new HtmlEmail();
email.setHostName(hostname);
email.setAuthenticator(new DefaultAuthenticator(username, password));
email.setSmtpPort(port);
email.setFrom(from, fromname);
email.setSubject(title);
email.setMsg(content);
email.addTo(mailAddress.split(mailAddressEndSeparator));
email.send();
} catch (Exception e) {
logger.error("Send Mail Error", e);
}
}
示例3: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void send(String absender, String empfaenger, String betreff, String text) {
try {
final Email email = new SimpleEmail();
email.setHostName(mailhost);
email.setSmtpPort(mailport);
email.setFrom(absender);
email.setSubject(betreff);
email.setMsg(text);
email.addTo(empfaenger);
email.send();
log.info("mail sent to: " + empfaenger);
} catch (final EmailException e) {
log.error(e.getMessage(), e);
}
}
示例4: sendEmail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private void sendEmail() throws EmailException, UnknownHostException {
List<String> addresses =
Lists.newArrayList(Splitter.on(',')
.omitEmptyStrings()
.trimResults()
.split(ADMIN_EMAIL.getAdmins()));
logger.info("Sending email to {}", addresses.toString());
Email email = new HtmlEmail();
email.setHostName(ADMIN_EMAIL.getHost());
email.setSocketTimeout(30000); // 30 seconds
email.setSocketConnectionTimeout(30000); // 30 seconds
for (String address : addresses) {
email.addTo(address);
}
email.setFrom(SorcererInjector.get().getModule().getName() + "@" +
InetAddress.getLocalHost().getHostName());
email.setSubject(title);
email.setMsg(body);
email.send();
}
示例5: sendEmail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private void sendEmail(final String address, final String taskId, final String taskName, final Throwable cause)
throws Exception
{
Email mail = new SimpleEmail();
mail.setSubject("Task execution failure");
mail.addTo(address);
// FIXME: This should ideally render a user-configurable template
StringWriter buff = new StringWriter();
PrintWriter out = new PrintWriter(buff);
if (taskId != null) {
out.format("Task ID: %s%n", taskId);
}
if (taskName != null) {
out.format("Task Name: %s%n", taskName);
}
if (cause != null) {
out.println("Stack-trace:");
cause.printStackTrace(out);
}
mail.setMsg(buff.toString());
emailManager.get().send(mail);
}
示例6: sendMail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private static void sendMail(String title, String message, String emailaddy) {
try {
Email email = new SimpleEmail();
email.setHostName(p.getProperty("mailserver.host"));
email.setSmtpPort(Integer.parseInt(p.getProperty("mailserver.port")));
if(p.getProperty("mailserver.useauth").equals("true"))
{
email.setAuthentication(p.getProperty("mailserver.user"), p.getProperty("mailserver.pass"));
}
if(p.getProperty("mailserver.usessl").equals("true"))
{
email.setSSLOnConnect(true);
}
else
{
email.setSSLOnConnect(false);
}
email.setFrom(p.getProperty("mailserver.from"));
email.setSubject("[MuninMX] " + title);
email.setMsg(message);
email.addTo(emailaddy);
email.send();
} catch (Exception ex) {
logger.warn("Unable to send Mail: " + ex.getLocalizedMessage());
}
}
示例7: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
void send(Mail mail) {
if(logger.isTraceEnabled()) {
logger.trace("New mail to send - {}", mail.subject);
}
Email email = smtp.emptyEmail();
email.setSubject(mail.subject);
try {
email.setFrom(mail.from);
email.setTo(Arrays.asList(new InternetAddress(mail.to)));
email.setMsg(mail.body);
if(logger.isDebugEnabled()) {
logger.debug("Send mail {}", mail.subject);
}
email.send();
} catch (EmailException | AddressException e) {
throw new RuntimeException(e);
}
}
示例8: sendEmail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public static String sendEmail(
String fromMail,
String fromName,
String to,
String subject,
String body,
boolean html) throws EmailException {
Email email;
if (html) {
email = EmailUtils.getHtmlEmail();
} else {
email = EmailUtils.getSimpleEmail();
}
String msgId = null;
email.setFrom(fromMail, fromName);
email.addTo(to);
email.setSubject(subject);
email.setMsg(body);
msgId = email.send();
LOG.infof("Sent e-mail with ID: %s", msgId);
return msgId;
}
示例9: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@RequestMapping("/send")
public HttpEntity<Void> send() throws EmailException {
// An unlucky fool hardcoded some smtp code here.
Email email = new SimpleEmail();
email.setHostName("localhost");
email.setSmtpPort(3025);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setFrom("[email protected]");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("[email protected]");
email.send();
return ResponseEntity.ok().build();
}
示例10: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@NotInServiceMenu
@Named("Enviar Correo")
public String send(final Cliente unCliente, final Oferta unaOferta) {
try {
Email email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(465);
email.setAuthentication("[email protected]", "modica1234");
email.setSSLOnConnect(true);
email.setFrom("[email protected]", "Resto Tesis");
email.setSubject("Ofertas para esta Semana!");
email.setMsg(printing.ofertaToText(unaOferta));
email.addTo(unCliente.getCorreo());
return email.send();
} catch (EmailException e) {
throw new servicio.correo.CorreoException(e.getMessage(), e);
}
}
示例11: createMailFor
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
/**
* Creates a new simple mail class and fills the subject and the body for the given person
* @param aPerson the person for whom the mail is addressed
*
* @return a mail instance
* @throws SdiException on any problem
*/
public Email createMailFor( Person<?> aPerson ) throws SdiException
{
Email email = new SimpleEmail();
try
{
email.addTo( aPerson.getEMail() );
String subject = myMailTextResolver.getResolvedSubject( aPerson );
myLog.debug( "resolved subject: " + subject);
email.setSubject( subject );
String body = myMailTextResolver.getResolvedBody( aPerson );
myLog.debug( "resolved body: " + body );
email.setMsg( body );
}
catch ( EmailException t )
{
throw new SdiException( "Problems setting up mail for " + aPerson.getEMail(),
t,
SdiException.EXIT_CODE_MAIL_ERROR );
}
return email;
}
示例12: put
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void put(final String code) throws IOException {
final Email email = new SimpleEmail();
email.setSubject(this.subject);
try {
email.setFrom("aintshy.com <[email protected]>");
email.setMsg(
String.format(
String.format("%s\n\n--\naintshy.com", this.body),
code
)
);
email.addTo(this.address);
this.postman.deliver(email);
} catch (final EmailException ex) {
throw new IOException(ex);
}
}
示例13: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
protected void send(EmailConfigDTO configDTO, ToSend message) {
try {
Email email = new SimpleEmail();
email.setHostName(server);
email.setSmtpPort(port);
email.setAuthenticator(new DefaultAuthenticator(login, password));
email.setSSLOnConnect(true);
email.setFrom(from);
email.setSubject(message.getSubject());
email.setMsg(message.getBody());
email.addTo(configDTO.getRecipient());
email.send();
} catch (EmailException ex) {
LOGGER.error("Send E-mail exception.", ex);
}
}
示例14: sendMail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void sendMail(String recipient, String subject, String content) throws FablabException {
try {
Email email = new SimpleEmail();
email.setHostName("localhost");
email.setSmtpPort(25);
email.setAuthenticator(new DefaultAuthenticator("test", "test"));
email.setFrom("[email protected]");
email.setSubject(subject);
email.setMsg(content);
email.addTo(recipient);
email.send();
} catch (EmailException ex) {
LOG.error("Canont send mail ", ex);
}
}
示例15: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
public boolean send(String to, String subject, String tpl, Context ctx) {
Email email = new SimpleEmail();
email.setHostName(config.get("mail.host"));
email.setAuthenticator(new DefaultAuthenticator(config.get("mail.user"), config.get("mail.passwd")));
if (config.getInt("mail.ssl", 0) == 1) {
email.setSSLOnConnect(true);
email.setSmtpPort(config.getInt("mail.port", 465));
} else {
email.setSmtpPort(config.getInt("mail.port", 25));
}
try {
email.setFrom(config.get("mail.from"));
email.setSubject("["+config.get("mail.suject.prefix", "Test") + "] " + subject);
email.setMsg(Segments.create(tpl).render(ctx).toString());
email.addTo(to);
email.send();
return true;
} catch (EmailException e) {
log.info("Send email fail", e);
return false;
}
}