当前位置: 首页>>代码示例>>Java>>正文


Java MessagingException.printStackTrace方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:28,代码来源:MailServiceImpl.java

示例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;
    }
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:21,代码来源:SimpleMailSender.java

示例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();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:28,代码来源:MailServiceImpl.java

示例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;
    }
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:33,代码来源:SimpleMailSender.java

示例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();
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:19,代码来源:AccountData.java

示例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 "";
        }
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:27,代码来源:EmailShield.java

示例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();
}
   }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:FolderTreeNode.java

示例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;
	}
}
 
开发者ID:SoapboxRaceWorld,项目名称:soapbox-race-core,代码行数:25,代码来源:RecoveryPasswordBO.java

示例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();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:31,代码来源:MailServiceImpl.java

示例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();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:31,代码来源:MailServiceImpl.java

示例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;
    }
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:32,代码来源:SimpleMailSender.java

示例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();
    }
}
 
开发者ID:hulang1024,项目名称:PTEAssistant,代码行数:38,代码来源:EamilReporter.java

示例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();
	}
}
 
开发者ID:JoMingyu,项目名称:Server-Quickstart-Vert.x,代码行数:13,代码来源:Mail.java

示例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;
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:32,代码来源:EmailShield.java

示例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
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:36,代码来源:UserRequestMaintenanceTx.java


注:本文中的javax.mail.MessagingException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。