本文整理匯總了Java中org.apache.commons.mail.SimpleEmail.setMsg方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleEmail.setMsg方法的具體用法?Java SimpleEmail.setMsg怎麽用?Java SimpleEmail.setMsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.mail.SimpleEmail
的用法示例。
在下文中一共展示了SimpleEmail.setMsg方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendSimpleEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public void sendSimpleEmail(String email_to, String subject, String msg) {
SimpleEmail email = new SimpleEmail();
try {
email.setDebug(debug);
email.setHostName(smtp);
email.addTo(email_to);
email.setFrom(email_from);
email.setAuthentication(email_from, email_password);
email.setSubject(subject);
email.setMsg(msg);
email.setSSL(ssl);
email.setTLS(tls);
email.send();
} catch (EmailException e) {
System.out.println(e.getMessage());
}
}
示例2: envia
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public static void envia(Registrar reg) {
try {
SimpleEmail email = new SimpleEmail();
email.setHostName("10.1.8.102");
email.addTo("[email protected]");
//email.addCc("[email protected]");
email.addCc("[email protected]");
email.addCc("[email protected]");
email.addCc("[email protected]");
//email.addCc("[email protected]");
//email.addCc("[email protected]");
email.setFrom("[email protected]");
email.setSubject("Error en tablealias");
String msg = String.format("%nServidor %s, pathInfo %s%nParametros %s ",reg.getNomServidor(), reg.getPagAccesa(), reg.getParametros());
email.setMsg("Categoria: " + reg.getCategoria() + " , Descripcion " + reg.getDescripcion() + msg + " \n Navegador:" + reg.getExplorador());
email.send();
} catch (EmailException ex1) {
ex1.printStackTrace();
}
}
示例3: sendText
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
@Override
public boolean sendText(String to, String subject, String content) throws EmailException {
SimpleEmail email = new SimpleEmail();
email.setHostName(host);// 設置使用發電子郵件的郵件服務器
email.addTo(to);
email.setAuthentication(user, password);
email.setFrom(from);
email.setSubject(subject);
email.setMsg(content);
if (port == 465) {
email.setSSLOnConnect(true);
email.setSslSmtpPort(Integer.toString(port)); // 若啟用,設置smtp協議的SSL端口號
}
else {
email.setSmtpPort(port);
}
email.send();
return true;
}
示例4: sendSimpleEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
/**
* Test sending an {@link SimpleEmail} rather than a {@link SmtpMessage}.
*/
@Test
public void sendSimpleEmail() throws Exception {
assertThat(this.sslMailServer.getReceivedMessages().length, is(0));
SimpleEmail email = new SimpleEmail();
email.setFrom("[email protected]");
email.setSubject("subject");
email.setMsg("content");
email.addTo("[email protected]");
email.setSentDate(UtcTime.now().toDate());
SmtpSender sender = new SmtpSender(email, new SmtpClientConfig("localhost", SMTP_SSL_PORT,
new SmtpClientAuthentication(USERNAME, PASSWORD), true));
sender.call();
// check mailbox after sending
MimeMessage[] receivedMessages = this.sslMailServer.getReceivedMessages();
assertThat(receivedMessages.length, is(1));
assertThat(receivedMessages[0].getSubject(), is("subject"));
assertThat(receivedMessages[0].getSentDate(), is(FrozenTime.now().toDate()));
Object expectedContent = "content";
assertThat(GreenMailUtil.getBody(receivedMessages[0]).trim(), is(expectedContent));
}
示例5: sendNormalEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
/**
* Send a verification email to the user's email account if exist.
*
* @param user
*/
public void sendNormalEmail(String subject, String content, String[] addresses ) {
if ( StringUtil.checkNotEmpty(subject) && StringUtil.checkNotEmpty(content) ) {
try {
String emailSmtp = GameDataManager.getInstance().getGameDataAsString(GameDataKey.EMAIL_SMTP, "mail.xinqihd.com");
SimpleEmail email = new SimpleEmail();
email.setHostName(emailSmtp);
email.setAuthenticator(new DefaultAuthenticator(EMAIL_FROM, "[email protected]"));
email.setFrom(EMAIL_FROM);
email.setSubject(subject);
email.setMsg(content);
email.setCharset("GBK");
for ( String address : addresses) {
if ( StringUtil.checkNotEmpty(address) ) {
email.addTo(address);
}
}
email.send();
} catch (EmailException e) {
logger.debug("Failed to send normal email", e);
}
}
}
示例6: sendTextEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
@Override
public void sendTextEmail(String to, String subject, String textBody) throws ServiceException {
SimpleEmail email = new SimpleEmail();
try {
setupEmail(email);
validateAddress(to);
email.addTo(to);
email.setSubject(subject);
email.setMsg(textBody);
email.send();
} catch (EmailException e) {
log.error("ZZZ.EmailException. To: " + to + " Subject: " + subject, e);
throw new ServiceException("Unable to send email.", e);
}
}
示例7: enviaEmailSimples
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
/**
* envia email simples (smente texto)
* Nome remetente, e-mail remetente, nome destinatario, e-mail destinatario,
* assunto, mensagem
* @param nomeRemetente
* @param nomeDestinatario
* @param emailRemetente
* @param emailDestinatario
* @param assunto
* @param mensagem
* @throws EmailException
*/
public void enviaEmailSimples(String nomeRementente, String emailRemetente,
String nomeDestinatario, String emailDestinatario,
String assunto, StringBuilder mensagem) throws EmailException {
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.hslife.com.br"); // o servidor SMTP para envio do e-mail
email.addTo(emailDestinatario, nomeDestinatario); //destinatário
email.setFrom(emailRemetente, nomeRementente); // remetente
email.setSubject(assunto); // assunto do e-mail
email.setMsg(mensagem.toString()); //conteudo do e-mail
email.setAuthentication("[email protected]", "real123");
//email.setSmtpPort(465);
//email.setSSL(true);
//email.setTLS(true);
email.send();
}
示例8: sendEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public static void sendEmail(String emailAddr, String verifyCode) {
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.163.com");
email.setAuthentication("[email protected]", "xingji19890326");
email.setCharset("UTF-8");
try{
email.addTo(emailAddr);
email.setFrom("[email protected]");
email.setSubject("Actsocial dashborad Check");
email.setMsg(verifyCode);
email.send();
}catch(EmailException e){
e.printStackTrace();
}
}
示例9: sendEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public static void sendEmail(String emailAddr, String verifyCode) {
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setAuthentication("[email protected]", "xingji19890326");
email.setCharset("UTF-8");
try{
email.addTo(emailAddr);
email.setFrom("[email protected]");
email.setSubject("Actsocial dashborad Check");
email.setMsg(verifyCode);
email.send();
}catch(EmailException e){
e.printStackTrace();
}
}
示例10: send
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public void send(EmailRequest request) throws EmailException, MalformedURLException {
SimpleEmail email = new SimpleEmail();
email.setFrom(request.getFromEmail(), request.getFromName());
email.setSubject(request.getSubject());
// Split multiple email addresses on either comma or semicolon
String[] toAddresses = request.getToEmail().split(",|;");
for (String thisToAddress : toAddresses) {
email.addTo(thisToAddress);
}
email.setMsg(request.getTextBody());
// Send email to multiple recipients even if one email address is invalid.
email.setSendPartial(true);
addStandardDetails(email);
email.send();
}
示例11: createTextOnlyEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
protected SimpleEmail createTextOnlyEmail(String text) {
SimpleEmail email = new SimpleEmail();
try {
email.setMsg(text);
return email;
} catch (EmailException e) {
throw new FlowableException("Could not create text-only email", e);
}
}
示例12: createTextOnlyEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
protected SimpleEmail createTextOnlyEmail(String text) {
SimpleEmail email = new SimpleEmail();
try {
email.setMsg(text);
return email;
} catch (EmailException e) {
throw new ActivitiException("Could not create text-only email", e);
}
}
示例13: sendTextMail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
private void sendTextMail(String fromEmail, String fromPasswd,String fromName,
String host,List<String> toEmailList,MailMsg mailMsg){
SimpleEmail email = new SimpleEmail();
try {
initEmail(email, fromEmail, fromPasswd,fromName, host, toEmailList, mailMsg);
email.setMsg(mailMsg.getContent());
email.send();
}
catch (EmailException e) {
e.printStackTrace();
}
}
示例14: sendPlainTextEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
public void sendPlainTextEmail(final List<String> to, final List<String> cc, final String subject, final String body, final SmtpProperties smtp) throws IOException, EmailException, EmailNotificationException {
logService.log(LogService.LOG_INFO, String.format("Sending email to = %s, cc= %s, subject = %s body = [%s]",
to,
JOINER_ON_COMMA.join(cc),
subject,
body));
final SimpleEmail email = new SimpleEmail();
email.setMsg(body);
sendEmail(to, cc, subject, email, precheckSmtp(smtp));
}
示例15: createTextOnlyEmail
import org.apache.commons.mail.SimpleEmail; //導入方法依賴的package包/類
protected SimpleEmail createTextOnlyEmail(String text) {
SimpleEmail email = new SimpleEmail();
try {
email.setMsg(text);
return email;
} catch (EmailException e) {
throw new ActivitiException("Could not create text-only email", e);
}
}