本文整理匯總了Java中javax.mail.MessagingException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java MessagingException.printStackTrace方法的具體用法?Java MessagingException.printStackTrace怎麽用?Java MessagingException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.mail.MessagingException
的用法示例。
在下文中一共展示了MessagingException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendMailWithUsername
import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Async
@Override
public void sendMailWithUsername(
@NotBlank @Email final String email,
@NotBlank final String username
) {
log.info("Called with e-mail {}, username {}", email, username);
try {
final JavaMailSenderImpl sender = new JavaMailSenderImpl();
final MimeMessage message = sender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo(email);
helper.setSubject("Recover username");
helper.setText("Your username: " + "<b>" + username + "</b>", true);
sendMail(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例2: sendTextMail
import javax.mail.MessagingException; //導入方法依賴的package包/類
public boolean sendTextMail(MailSenderInfo mailInfo) {
MyAuthenticator authenticator = null;
Properties pro = mailInfo.getProperties();
if (mailInfo.isValidate()) {
authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
}
try {
Message mailMessage = new MimeMessage(Session.getInstance(pro, authenticator));
mailMessage.setFrom(new InternetAddress(mailInfo.getFromAddress()));
mailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(mailInfo.getToAddress()));
mailMessage.setSubject(mailInfo.getSubject());
mailMessage.setSentDate(new Date());
mailMessage.setText(mailInfo.getContent());
Transport.send(mailMessage);
return true;
} catch (MessagingException ex) {
ex.printStackTrace();
return false;
}
}
示例3: sendMailWithNewPassword
import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Async
@Override
public void sendMailWithNewPassword(
@NotBlank @Email final String email,
@NotBlank final String newPassword
) {
log.info("Called with e-mail {}, newPassword {}", email, newPassword);
try {
final JavaMailSenderImpl sender = new JavaMailSenderImpl();
final MimeMessage message = sender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo(email);
helper.setSubject("Recover password");
helper.setText("Your new password: " + "<b>" + newPassword + "</b>", true);
sendMail(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例4: sendAttachMail
import javax.mail.MessagingException; //導入方法依賴的package包/類
public boolean sendAttachMail(MailSenderInfo mailInfo) {
MyAuthenticator authenticator = null;
Properties pro = mailInfo.getProperties();
if (mailInfo.isValidate()) {
authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
}
try {
Message mailMessage = new MimeMessage(Session.getInstance(pro, authenticator));
mailMessage.setFrom(new InternetAddress(mailInfo.getFromAddress()));
mailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(mailInfo.getToAddress()));
mailMessage.setSubject(mailInfo.getSubject());
mailMessage.setSentDate(new Date());
Multipart multi = new MimeMultipart();
BodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setContent(mailInfo.getContent(), "text/html; charset=utf-8");
multi.addBodyPart(textBodyPart);
for (String path : mailInfo.getAttachFileNames()) {
DataSource fds = new FileDataSource(path);
BodyPart fileBodyPart = new MimeBodyPart();
fileBodyPart.setDataHandler(new DataHandler(fds));
fileBodyPart.setFileName(path.substring(path.lastIndexOf("/") + 1));
multi.addBodyPart(fileBodyPart);
}
mailMessage.setContent(multi);
mailMessage.saveChanges();
Transport.send(mailMessage);
return true;
} catch (MessagingException ex) {
ex.printStackTrace();
return false;
}
}
示例5: destroy
import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
* Frees up resources used by this object.
*/
public synchronized void destroy()
{
if (_store != null)
{
try
{
_store.close();
_store = null;
}
catch (MessagingException e)
{
e.printStackTrace();
}
}
}
示例6: sendEmail
import javax.mail.MessagingException; //導入方法依賴的package包/類
private String sendEmail() throws IOException {
try {
if (attachment_file_path != null)
attachedFile = new File(attachment_file_path);
if (order > 0) {
if (attachment_file_path == null) {
mService.users().messages().send("me", createMessageWithEmail(createEmail(message_reciption, userEmail, message_subject, message_body))).execute();
}else {
if (attachedFile.exists())
mService.users().messages().send("me", createMessageWithEmail(createEmailWithAttachment(message_reciption, userEmail, message_subject, message_body, attachment_file_path))).execute();
else {
mService.users().messages().send("me", createMessageWithEmail(createEmail(message_reciption, userEmail, message_subject, message_body))).execute();
// cancel(true);
// if (eventHandler != null)
// eventHandler.stopProgress();
return "";
}
}
}else
mService.users().labels().list("me").execute();
} catch (MessagingException e) {
e.printStackTrace();
return null;
}
return "";
}
示例7: loadChildren
import javax.mail.MessagingException; //導入方法依賴的package包/類
protected void loadChildren() {
// if it is a leaf, just say we have loaded them
if (isLeaf()) {
hasLoaded = true;
return;
}
try {
// Folder[] sub = folder.listSubscribed();
Folder[] sub = folder.list();
// add a FolderTreeNode for each Folder
int num = sub.length;
for(int i = 0; i < num; i++) {
FolderTreeNode node = new FolderTreeNode(sub[i]);
// we used insert here, since add() would make
// another recursive call to getChildCount();
insert(node, i);
}
} catch (MessagingException me) {
me.printStackTrace();
}
}
示例8: sendEmail
import javax.mail.MessagingException; //導入方法依賴的package包/類
private Boolean sendEmail(String randomKey, UserEntity userEntity) {
try {
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(Config.getEmailFrom()));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(userEntity.getEmail()));
message.setSubject("Recovery Password Email");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Dear user,\n\n");
stringBuilder.append("Someone requested to recover forgotten password in our soapbox race world server.\n\n");
stringBuilder.append("If wasn't you, just ignore this email.\n\n");
stringBuilder.append("You can click this link to reset your password:\n\n");
stringBuilder.append(Config.getServerAddress());
stringBuilder.append("/soapbox-race-core/password.jsp?randomKey=");
stringBuilder.append(randomKey);
stringBuilder.append("\n\nThanks for playing!\n\n");
stringBuilder.append("\n\nSBRW Team.\n");
message.setText(stringBuilder.toString());
Transport.send(message);
return true;
} catch (MessagingException mex) {
mex.printStackTrace();
return false;
}
}
示例9: sendMailWithActivationToken
import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Async
@Override
public void sendMailWithActivationToken(
@NotBlank @Email final String email,
@NotBlank final String token
) {
log.info("Called with e-mail {}, token {}", email, token);
try {
final JavaMailSenderImpl sender = new JavaMailSenderImpl();
final MimeMessage message = sender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo(email);
helper.setSubject("Complete registration");
helper.setText("To activation your account, click the link below:<br />"
+ "<a href='" + "https://localhost:8443" + "/register/thanks?token=" + token + "'>" +
"Click here to complete your registration" +
"</a>", true);
sendMail(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例10: sendMailWithEmailChangeToken
import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Async
@Override
public void sendMailWithEmailChangeToken(
@NotBlank @Email final String email,
@NotBlank final String token
) {
log.info("Called with e-mail {}, token {}", email, token);
try {
final JavaMailSenderImpl sender = new JavaMailSenderImpl();
final MimeMessage message = sender.createMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo(email);
helper.setSubject("Change e-mail");
helper.setText("Change e-mail address, click the link below:<br />"
+ "<a href='" + "https://localhost:8443" + "/settings/changeEmail/thanks?token=" + token + "'>" +
"Click here to complete the change of your e-mail" +
"</a>", true);
sendMail(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例11: sendHtmlMail
import javax.mail.MessagingException; //導入方法依賴的package包/類
public boolean sendHtmlMail(MailSenderInfo mailInfo) {
XLog.d("發送網頁版郵件!");
MyAuthenticator authenticator = null;
Properties pro = mailInfo.getProperties();
if (mailInfo.isValidate()) {
authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
}
try {
Message mailMessage = new MimeMessage(Session.getInstance(pro, authenticator));
mailMessage.setFrom(new InternetAddress(mailInfo.getFromAddress()));
String[] receivers = mailInfo.getReceivers();
Address[] tos = new InternetAddress[receivers.length];
for (int i = 0; i < receivers.length; i++) {
tos[i] = new InternetAddress(receivers[i]);
}
mailMessage.setRecipients(Message.RecipientType.TO, tos);
mailMessage.setSubject(mailInfo.getSubject());
mailMessage.setSentDate(new Date());
Multipart mainPart = new MimeMultipart();
BodyPart html = new MimeBodyPart();
html.setContent(mailInfo.getContent(), "text/html; charset=utf-8");
mainPart.addBodyPart(html);
mailMessage.setContent(mainPart);
Transport.send(mailMessage);
return true;
} catch (MessagingException ex) {
ex.printStackTrace();
return false;
}
}
示例12: report
import javax.mail.MessagingException; //導入方法依賴的package包/類
public void report(UserSetting userSetting, SearchResult searchResult, int resultState) {
if(! (boolean)config.get("enableMailReport"))
return;
final Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.user", config.get("fromEmailUser"));
props.put("mail.password", config.get("fromEmailPassword"));
// 構建授權信息,用於進行SMTP進行身份驗證
Authenticator authenticator = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(props.getProperty("mail.user"), props.getProperty("mail.password"));
}
};
Session mailSession = Session.getInstance(props, authenticator);
try {
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(props.getProperty("mail.user")));
message.setRecipient(RecipientType.TO, new InternetAddress(config.get("toEmailUser").toString()));
message.setSubject("PTE助手通知");
String content = String.format("賬號 %s 已搜索到可用約會: 時間=%s, 地點=%s",
userSetting.user.username, CalendarUtils.chinese(searchResult.apptTime), searchResult.testCenter);
if(resultState > -1) {
content += "<br>";
content += resultState == 1 ? "並報名成功" : "但報名失敗";
}
message.setContent(content, "text/html;charset=UTF-8");
Transport.send(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例13: sendMail
import javax.mail.MessagingException; //導入方法依賴的package包/類
public static void sendMail(String recipient, String subject, String body) {
try {
mimeMessage.setFrom(new InternetAddress(SENDER_ID + "@naver.com"));
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
mimeMessage.setSubject(subject);
mimeMessage.setText(body);
Transport.send(mimeMessage);
} catch (MessagingException e) {
e.printStackTrace();
}
}
示例14: createEmailWithAttachment
import javax.mail.MessagingException; //導入方法依賴的package包/類
public static MimeMessage createEmailWithAttachment(String to, String from, String subject,
String bodyText,String filePath) throws MessagingException{
File file = new File(filePath);
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage email = new MimeMessage(session);
Multipart multipart = new MimeMultipart();
InternetAddress tAddress = new InternetAddress(to);
InternetAddress fAddress = new InternetAddress(from);
email.setFrom(fAddress);
email.addRecipient(javax.mail.Message.RecipientType.TO, tAddress);
email.setSubject(subject);
if (file.exists()) {
source = new FileDataSource(filePath);
messageFilePart = new MimeBodyPart();
messageBodyPart = new MimeBodyPart();
try {
messageBodyPart.setText(bodyText);
messageFilePart.setDataHandler(new DataHandler(source));
messageFilePart.setFileName(file.getName());
multipart.addBodyPart(messageBodyPart);
multipart.addBodyPart(messageFilePart);
email.setContent(multipart);
} catch (MessagingException e) {
e.printStackTrace();
}
}else
email.setText(bodyText);
return email;
}
示例15: postCreate
import javax.mail.MessagingException; //導入方法依賴的package包/類
/** This method is invoked after the domain object has been created.*/
private void postCreate(UOW uow, UserRequestMaintenanceCreateInDto input, UserRequest domain, boolean fromPrevalidate)
throws FrameworkException, ApplicationExceptions {
// .//GEN-END:_postCreate_1_be
// Add custom code //GEN-FIRST:_postCreate_1
EmailerBean email = new EmailerBean();
UserRequest domainCreated = new UserRequest();
Criteria criteria = new Criteria();
criteria.setTable( UserRequestMeta.getName() );
log.debug("This is the dto's final value" + input.getUrl());
criteria.addCriteria(UserRequestMeta.USER_NAME, domain.getUserName());
criteria.addCriteria(UserRequestMeta.FIRST_NAME , domain.getFirstName());
criteria.addCriteria(UserRequestMeta.LAST_NAME , domain.getLastName());
criteria.addCriteria(UserRequestMeta.CREATED_ON , domain.getCreatedOn());
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domainCreated = (UserRequest) itr.next();
if (domainCreated != null) {
try {
String url = input.getUrl() + domainCreated.getRequestId();
url = replaceAll(url , "Jaffa.User" , "Jaffa.Admin");
String[] to = new String[] {"[email protected]"};
email.sendMail(to, "request for user account" , url);
} catch (MessagingException e) {
e.printStackTrace();
}
}
input.setRequestId(domainCreated.getRequestId());
// .//GEN-LAST:_postCreate_1
// .//GEN-BEGIN:_postCreate_2_be
}