Java Code Examples for org.apache.commons.mail.EmailException#printStackTrace()
The following examples show how to use
org.apache.commons.mail.EmailException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MailUtil.java From xiaoV with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") public static void sendMail(String content) { MailSenderInfo mailInfo = getMailSenderInfo(content); MultiPartEmail email = new MultiPartEmail(); try { email.setTLS(mailInfo.isSslenable()); email.setHostName(mailInfo.getMailServerHost()); email.setAuthentication(mailInfo.getUserName(), mailInfo.getPassword());// 用户名和密码 email.setFrom(mailInfo.getFromAddress()); // 发送方 email.addTo(mailInfo.getToAddress());// 接收方 email.setSubject(mailInfo.getSubject()); // 标题 email.setCharset("UTF-8"); email.setMsg(mailInfo.getContent()); // 内容 email.send(); } catch (EmailException e) { e.printStackTrace(); } }
Example 2
Source File: MailUtil.java From shop with GNU General Public License v3.0 | 6 votes |
/** * 发送邮件给指定人,需要主题和内容 * @param user * @param title * @param content */ public static void sendMail(String user, String title, String content) { SimpleEmail email = new SimpleEmail(); email.setCharset("UTF8"); email.setHostName("smtp.163.com"); email.setAuthentication(USERNAME, PASSWORD); try { email.setFrom(USERNAME); email.addTo(user); email.setSubject(title); email.setMsg(content); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
Example 3
Source File: EmailManager.java From Notebook with Apache License 2.0 | 6 votes |
private void attachFile(ImageHtmlEmail email, EmailFrom emailFrom) { if(!emailFrom.isAttached()){ return; } // �������� EmailAttachment attachment = new EmailAttachment(); // ����·�� attachment.setPath(emailFrom.getAttachmentPath()); // ����·�� // attachment.setURL(new URL("http://www.baidu.com/xx.zip")); attachment.setDisposition(EmailAttachment.ATTACHMENT); // �������� // attachment.setDescription("����Ͷ�帽��"); // �������� attachment.setName(emailFrom.getAttachmentName()); // ������Ӷ������ // email.attach(attachment1); // email.attach(attachment2); try { email.attach(attachment); } catch (EmailException e) { e.printStackTrace(); } }
Example 4
Source File: SendEmail.java From SpyGen with Apache License 2.0 | 5 votes |
public SendEmail(String subject, String msg) { try { email = new MultiPartEmail(); email.setDebug(DEBUG); email.setHostName(SMTP); email.setSSL(SSL); email.addTo(Settings.receiverMail); email.setFrom(Settings.senderMail); email.setAuthentication(Settings.senderMail, Settings.senderPassword); email.setSubject(subject); email.setMsg(msg); } catch(EmailException ee) { ee.printStackTrace(); } }
Example 5
Source File: SendEmail.java From SpyGen with Apache License 2.0 | 5 votes |
public void attach(String file, String description) { File f = new File(file); EmailAttachment attachment = new EmailAttachment(); attachment.setPath(f.getPath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription(description); attachment.setName(f.getName()); try { this.email.attach(attachment); } catch (EmailException se) { se.printStackTrace(); } }
Example 6
Source File: SendEmail.java From SpyGen with Apache License 2.0 | 5 votes |
public void send() { System.out.println("try to send ..."); try { email.send(); System.out.println("Success send it !"); cleanFoldersAfterSend(); } catch (EmailException e) { System.out.println("Error sending !"); e.printStackTrace(); } }
Example 7
Source File: GenerateAttachment.java From nifi with Apache License 2.0 | 5 votes |
public MimeMessage SimpleEmailMimeMessage() { Email email = new SimpleEmail(); try { email.setFrom(from); email.addTo(to); email.setSubject(subject); email.setMsg(message); email.setHostName(hostName); email.buildMimeMessage(); } catch (EmailException e) { e.printStackTrace(); } return email.getMimeMessage(); }
Example 8
Source File: RegistrationController.java From MaxKey with Apache License 2.0 | 4 votes |
@RequestMapping(value={"/register"}) public ModelAndView reg(@ModelAttribute("registration") Registration registration) { _logger.debug("Registration /registration/register."); _logger.debug(""+registration); ModelAndView modelAndView= new ModelAndView("registration/registered"); UserInfo userInfo =registrationService.queryUserInfoByEmail(registration.getWorkEmail()); if(userInfo!=null){ modelAndView.addObject("registered", 1); return modelAndView; } registration.setId(registration.generateId()); registrationService.insert(registration); HtmlEmail email = new HtmlEmail(); try { email.setHostName(applicationConfig.getEmailConfig().getSmtpHost()); email.setSmtpPort(applicationConfig.getEmailConfig().getPort()); email.setAuthenticator(new DefaultAuthenticator(applicationConfig.getEmailConfig().getUsername(), applicationConfig.getEmailConfig().getPassword())); email.addTo(registration.getWorkEmail(), registration.getLastName()+registration.getFirstName()); email.setFrom(applicationConfig.getEmailConfig().getSender(), "ConnSec"); email.setSubject("ConnSec Cloud Identity & Access Registration activate Email ."); String activateUrl=WebContext.getHttpContextPath()+"/registration/forward/activate/"+registration.getId(); // set the html message String emailText="<html>"; emailText+="<a href='"+activateUrl+"'>activate</a><br>"; emailText+=" or copy "+activateUrl+" to brower."; emailText+="</html>"; email.setHtmlMsg(emailText); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // send the email email.send(); } catch (EmailException e) { // TODO Auto-generated catch block e.printStackTrace(); } modelAndView.addObject("registered", 0); return modelAndView; }