public static void setNonHtmlMessage(CommandSender sender, String[] args) { if (inProgress(sender.getName())) { switch (getCurrentEmail(sender.getName())) { case "simple": LogHelper.showWarning("emailNonHtmlNotAllowed", sender); return; case "multi": LogHelper.showWarning("emailNonHtmlNotAllowed", sender); return; case "html": break; default: LogHelper.showWarning("emailNotInProgressEdit", sender); return; } HtmlEmail email = htmlEmail.get(sender.getName()); try { email.setMsg(Utils.implode(args, " ")); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showWarning("emailNonHtmlMessageSet", sender); htmlEmail.put(sender.getName(), email); } else { LogHelper.showWarning("emailNotInProgressEdit", sender); } }
protected HtmlEmail prepareEmail(String name, String toMail) { with("to_name", name); with("to_email", toMail); with("host", appLocation); if (!hasSigner) { with("signer", this.localization.getMessage("signer")); } HtmlEmail email = new HtmlEmail(); email.setCharset("utf-8"); try { addEmbeddables(email); addAttachments(email); email.addTo(toMail, name); boolean hasNoSubjectDefined = this.localization.getMessage(name, nameParameters).equals("???" + name + "???"); if (hasNoSubjectDefined) { throw new IllegalArgumentException("Subject not defined for email template : " + name); } else { email.setSubject(this.localization.getMessage(this.templateName, nameParameters)); } email.setHtmlMsg(this.template.getContent()); } catch (Exception e) { throw new RuntimeException(e); } return email; }
/** * 发送模板邮件 * * @param toMailAddr 收信人地址 * @param subject email主题 * @param templatePath 模板地址 * @param map 模板map */ public static void sendFtlMail( String toMailAddr, String subject, String templatePath, Map<String, Object> map) { Template template = null; Configuration freeMarkerConfig = null; HtmlEmail hemail = new HtmlEmail(); try { hemail.setHostName(getHost(from)); hemail.setSmtpPort(getSmtpPort(from)); hemail.setCharset(charSet); hemail.addTo(toMailAddr); hemail.setFrom(from, fromName); hemail.setAuthentication(username, password); hemail.setSubject(subject); freeMarkerConfig = new Configuration(); freeMarkerConfig.setDirectoryForTemplateLoading(new File(getFilePath())); // 获取模板 template = freeMarkerConfig.getTemplate(getFileName(templatePath), new Locale("Zh_cn"), "UTF-8"); // 模板内容转换为string String htmlText = FreeMarkerTemplateUtils.processTemplateIntoString(template, map); System.out.println(htmlText); hemail.setMsg(htmlText); hemail.send(); System.out.println("email send true!"); } catch (Exception e) { e.printStackTrace(); System.out.println("email send error!"); } }
@Override public void sendMail(String emailRecipient, String message) { try { /*Should use subservice to get administrative resource resolver instead of this code*/ ResourceResolver resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null); Resource templateResource = resourceResolver.getResource(RabbitMQUtil.EMAIL_TEMPLATE_PATH); if (templateResource.getChild("file") != null) { templateResource = templateResource.getChild("file"); } ArrayList<InternetAddress> emailRecipients = new ArrayList<InternetAddress>(); final MailTemplate mailTemplate = MailTemplate.create( templateResource.getPath(), templateResource.getResourceResolver().adaptTo(Session.class)); HtmlEmail email = new HtmlEmail(); Map<String, String> mailTokens = new HashMap<String, String>(); mailTokens.put("message", message); mailTokens.put("subject", "Dummy Subject"); mailTokens.put("email", emailRecipient); if (mailTemplate != null) { emailRecipients.add(new InternetAddress(emailRecipient)); email.setTo(emailRecipients); email.setSubject("Dummy Mail"); email.setTextMsg(message); messageGateway = messageGatewayService.getGateway(HtmlEmail.class); messageGateway.send(email); } } catch (Exception e) { /*Put message in queue again in case of exception.. Based on type of exception, it can be decided whether it has to be put in queue again or not*/ RabbitMQUtil.addMessageToQueue(scrService); e.printStackTrace(System.out); } }
/** * Handle an event broadcast from another component * * @param event {@link org.blojsom.event.Event} to be handled */ public void handleEvent(Event event) { if (event instanceof CommentAddedEvent) { HtmlEmail email = new HtmlEmail(); CommentAddedEvent commentAddedEvent = (CommentAddedEvent) event; if (commentAddedEvent.getBlog().getBlogEmailEnabled().booleanValue() && _mailServer != null) { try { setupEmail(commentAddedEvent.getBlog(), commentAddedEvent.getEntry(), email); Map emailTemplateContext = new HashMap(); emailTemplateContext.put(BlojsomConstants.BLOJSOM_BLOG, commentAddedEvent.getBlog()); emailTemplateContext.put( BLOJSOM_COMMENT_PLUGIN_BLOG_COMMENT, commentAddedEvent.getComment()); emailTemplateContext.put(BLOJSOM_COMMENT_PLUGIN_BLOG_ENTRY, commentAddedEvent.getEntry()); String htmlText = mergeTemplate( COMMENT_PLUGIN_EMAIL_TEMPLATE_HTML, commentAddedEvent.getBlog(), emailTemplateContext); String plainText = mergeTemplate( COMMENT_PLUGIN_EMAIL_TEMPLATE_TEXT, commentAddedEvent.getBlog(), emailTemplateContext); email.setHtmlMsg(htmlText); email.setTextMsg(plainText); String emailPrefix = (String) commentAddedEvent.getBlog().getProperties().get(COMMENT_PREFIX_IP); if (BlojsomUtils.checkNullOrBlank(emailPrefix)) { emailPrefix = DEFAULT_COMMENT_PREFIX; } email = (HtmlEmail) email.setSubject(emailPrefix + commentAddedEvent.getEntry().getTitle()); email.send(); } catch (EmailException e) { if (_logger.isErrorEnabled()) { _logger.error(e); } } } else { if (_logger.isErrorEnabled()) { _logger.error( "Missing SMTP servername servlet initialization parameter: " + EmailConstants.SMTPSERVER_IP); } } } }
protected void addEmbeddables(HtmlEmail email) throws EmailException { for (Entry<String, DataSource> entry : toEmbed.entrySet()) { String key = entry.getKey(); String cid = email.embed(entry.getValue(), key); with(key, "cid:" + cid); } }
@SuppressWarnings("unchecked") static String[] composeReadableRecipientList(HtmlEmail email) { String[] RRL = {"To: ", "Cc: ", "Bcc: "}; Iterator<String> toIT = email.getToAddresses().iterator(), ccIT = email.getCcAddresses().iterator(), bccIT = email.getBccAddresses().iterator(); while (toIT.hasNext()) { RRL[0] += toIT.next() + ", "; } while (ccIT.hasNext()) { RRL[1] += ccIT.next() + ", "; } while (bccIT.hasNext()) { RRL[2] += bccIT.next() + ", "; } return RRL; }
static void editRecipientHtml(CommandSender sender, String emailString, RecipientAction action) { HtmlEmail email = htmlEmail.get(sender.getName()); switch (action) { case ADD: try { email.addTo(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); return; case ADD_BCC: try { email.addBcc(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); return; case ADD_CC: try { email.addCc(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); return; case DELETE: try { email = removeRecipient(email, emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientDeleted", sender); return; case LIST: sender.sendMessage(composeReadableRecipientList(email)); default: } htmlEmail.put(sender.getName(), email); }
static HtmlEmail setAuthentication(HtmlEmail email) { if (!(CommandsEX.getConf().getString("Email.Username").isEmpty() && CommandsEX.getConf().getString("Email.Password").isEmpty())) { email.setAuthentication( CommandsEX.getConf().getString("Email.Username"), CommandsEX.getConf().getString("Email.Password")); } return email; }
/** * 发送普通邮件 * * @param toMailAddr 收信人地址 * @param subject email主题 * @param message 发送email信息 */ public static void sendCommonMail(String toMailAddr, String subject, String message) { HtmlEmail hemail = new HtmlEmail(); try { hemail.setHostName(getHost(from)); hemail.setSmtpPort(getSmtpPort(from)); hemail.setCharset(charSet); hemail.addTo(toMailAddr); hemail.setFrom(from, fromName); hemail.setAuthentication(username, password); hemail.setSubject(subject); hemail.setMsg(message); hemail.send(); System.out.println("email send true!"); } catch (Exception e) { e.printStackTrace(); System.out.println("email send error!"); } }
public static void compose(CommandSender sender, String type) { if (inProgress(sender.getName())) { LogHelper.showWarning("emailAlreadyInProgress", sender); return; } if (type.equalsIgnoreCase("simple")) { SimpleEmail email = new SimpleEmail(); email.setHostName(CommandsEX.getConf().getString("Email.Host")); try { email.setFrom(CommandsEX.getConf().getString("Email.From")); } catch (EmailException e) { sendErrorMessage(sender, e); return; } email = setAuthentication(email); simpleEmail.put(sender.getName(), email); } else if (type.equalsIgnoreCase("attachment")) { MultiPartEmail email = new MultiPartEmail(); email.setHostName(CommandsEX.getConf().getString("Email.Host")); try { email.setFrom(CommandsEX.getConf().getString("Email.From")); } catch (EmailException e) { sendErrorMessage(sender, e); return; } email = setAuthentication(email); multiEmail.put(sender.getName(), email); } else if (type.equalsIgnoreCase("html")) { HtmlEmail email = new HtmlEmail(); email.setHostName(CommandsEX.getConf().getString("Email.Host")); try { email.setFrom(CommandsEX.getConf().getString("Email.From")); } catch (EmailException e) { sendErrorMessage(sender, e); return; } email = setAuthentication(email); htmlEmail.put(sender.getName(), email); } LogHelper.showInfo("emailCreated", sender); }
public void sendEmail() { try { List<Emails> emails = emailsDao.getEmailsByStatus('N'); if (!ITeachUtility.isEmptyList(emails)) { for (Emails emailToSend : emails) { try { HtmlEmail email = new HtmlEmail(); email.setHostName(ITeachUtility.getPropValue("hostName", true)); email.setSmtpPort(Integer.parseInt(ITeachUtility.getPropValue("portNumber", true))); email.setAuthenticator( new DefaultAuthenticator( ITeachUtility.getPropValue("userName", true), ITeachUtility.getPropValue("password", true))); email.addTo(emailToSend.getEmailTo()); email.setFrom(emailToSend.getEmailFrom(), emailToSend.getEmailFromName()); email.setSubject(emailToSend.getEmailSub()); String emailContent = emailToSend.getEmailBody(); /* * if(StringUtils.isNotBlank(emailToSend. * getEmailAttachments ())){ Set<String> * attachments=ITeachUtility.getStringAsSet(emailToSend. * getEmailAttachments(), ","); } */ // set the html message email.setHtmlMsg("<html>" + emailContent + "</html>"); email.send(); emailToSend.setSendAttempt( emailToSend.getSendAttempt() == null ? 1 : (emailToSend.getSendAttempt() + 1)); emailToSend.setEmailStatus('S'); emailToSend.setSentOn(Calendar.getInstance().getTime()); System.out.println("sent email to " + emailToSend.getEmailTo()); } catch (EmailException e) { // if any exception then updating the attempt. emailToSend.setSendAttempt( emailToSend.getSendAttempt() == null ? 1 : (emailToSend.getSendAttempt() + 1)); e.printStackTrace(); } emailsDao.updateEmails(emailToSend); } } else { System.out.println("No email to send."); } } catch (ITeachException ex) { ex.printStackTrace(); } }
@Signature public PHtmlEmail attach( Environment env, Memory content, String type, String name, String description) throws EmailException, MessagingException, IOException { InputStream is = Stream.getInputStream(env, content); try { htmlEmail.attach( new ByteArrayDataSource(is, type), name, description, EmailAttachment.ATTACHMENT); return this; } finally { Stream.closeStream(env, is); } }
public void sendSmtpTestMail( String smtpFromMail, String smtpHost, Integer smtpPort, String smtpUsername, String smtpPassword, String toMail) { SystemConfig systemConfig = SystemConfigUtil.getSystemConfig(); MailConfig mailConfig = TemplateConfigUtil.getMailConfig(MailConfig.SMTP_TEST); String subject = mailConfig.getSubject(); String templateFilePath = mailConfig.getTemplateFilePath(); try { email = new HtmlEmail(); email.setHostName(systemConfig.getSmtpHost()); email.setSmtpPort(systemConfig.getSmtpPort()); email.setAuthenticator( new DefaultAuthenticator(systemConfig.getSmtpUsername(), systemConfig.getSmtpPassword())); email.setSSLOnConnect(true); WebAppResourceLoader resourceLoader = new WebAppResourceLoader(); Configuration cfg = Configuration.defaultConfiguration(); GroupTemplate gt = new GroupTemplate(resourceLoader, cfg); Template template = gt.getTemplate(templateFilePath); template.binding("systemConfig", systemConfig); String text = template.render(); email.setFrom( MimeUtility.encodeWord(systemConfig.getShopName()) + " <" + systemConfig.getSmtpFromMail() + ">"); email.setSubject(subject); email.setMsg(text); email.addTo(toMail); email.send(); } catch (EmailException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public boolean sendMail( String subject, String templateFilePath, Map<String, Object> data, String toMail) { boolean isSend = false; try { SystemConfig systemConfig = SystemConfigUtil.getSystemConfig(); email = new HtmlEmail(); email.setHostName(systemConfig.getSmtpHost()); email.setSmtpPort(systemConfig.getSmtpPort()); email.setAuthenticator( new DefaultAuthenticator(systemConfig.getSmtpUsername(), systemConfig.getSmtpPassword())); email.setSSLOnConnect(true); WebAppResourceLoader resourceLoader = new WebAppResourceLoader(); Configuration cfg = Configuration.defaultConfiguration(); GroupTemplate gt = new GroupTemplate(resourceLoader, cfg); Template template = gt.getTemplate(templateFilePath); template.binding(data); String text = template.render(); email.setFrom( MimeUtility.encodeWord(systemConfig.getShopName()) + " <" + systemConfig.getSmtpFromMail() + ">"); email.setSubject(subject); email.setMsg(text); email.addTo(toMail); email.send(); isSend = true; } catch (EmailException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return isSend; }
public boolean send(String to, String subject, String html) { try { HtmlEmail email = ioc.get(HtmlEmail.class); email.setSubject(subject); email.setHtmlMsg(html); email.addTo(to); email.buildMimeMessage(); email.sendMimeMessage(); return true; } catch (Throwable e) { log.info("send email fail", e); return false; } }
static HtmlEmail removeRecipient(HtmlEmail email, String emailToRemove) throws EmailException { List<String> to = Utils.noGenericTypeToStringType(email.getToAddresses()), cc = Utils.noGenericTypeToStringType(email.getCcAddresses()), bcc = Utils.noGenericTypeToStringType(email.getBccAddresses()); if (to.contains(emailToRemove)) { to.remove(emailToRemove); email.setTo(to); } else if (cc.contains(emailToRemove)) { cc.remove(emailToRemove); email.setCc(cc); } else if (bcc.contains(emailToRemove)) { bcc.remove(emailToRemove); email.setBcc(bcc); } return email; }
private void sendFailedJobEmail(TnrsJob job) throws Exception { if (!job.email()) return; HtmlEmail response = new HtmlEmail(); response.setHostName("localhost"); response.setSmtpPort(25); response.setFrom("*****@*****.**"); response.setSubject("TNRS Job failure"); response.setMsg( "Your TNRS " + job.getTypeString() + " job for the file " + job.getRequest().getOriginalFilename() + " failed on " + dateFormat.format(new Date()) + ". Please provide the job key and if possible the name list you were runing so we can better help you diagnose the issue. \n\n" + "The job key is:" + job.getRequest().getId() + "\n\n" + "Thank you,\n" + "iPlant Collaborative"); response.addTo(job.getRequest().getEmail()); response.send(); }
@Signature public PHtmlEmail setFrom(String email, String name, String charset) throws EmailException { htmlEmail.setFrom(email, name, charset); return this; }
@Signature public PHtmlEmail setHeaders(Map<String, String> map) { htmlEmail.setHeaders(map); return this; }
static void setBouncebackHtml(CommandSender sender, String bounceback) { HtmlEmail email = htmlEmail.get(sender.getName()); email.setBounceAddress(bounceback); LogHelper.showInfo("emailBouncebackSet", sender); htmlEmail.put(sender.getName(), email); }
static void editSubjectHTML(CommandSender sender, String[] args) { HtmlEmail email = htmlEmail.get(sender.getName()); email.setSubject(Utils.implode(args, " ")); LogHelper.showInfo("emailSubjectSet", sender); htmlEmail.put(sender.getName(), email); }
@Signature public String send(PEmailBackend backend) throws EmailException { backend._apply(htmlEmail); return htmlEmail.send(); }
public boolean sendRegistartionConfirmationMail(QuasarMailConfiguration qmc, String... emailids) { try { HtmlEmail email = new HtmlEmail(); email.setHostName(qmc.getHost()); email.setSmtpPort(Integer.parseInt(qmc.getPort())); email.setAuthentication(qmc.getAdimnusername(), qmc.getAdminpassword()); email.setSSLOnConnect(Boolean.parseBoolean(qmc.getStarttls())); email.setFrom(qmc.getAdimnusername()); email.setSubject("TestMail"); // MailChimp // email.setHtmlMsg("<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Insert // title here</title></head><body><table id=\"studentdetail\" style=\"background-color: // graytext;font-family: sans-serif;padding: 10px;-webkit-border-radius: // 4px;-moz-border-radius: 4px;border-radius: 4px;box-shadow: 0 4px 4px -4px rgba(0, 0, 0, // 0.7);-moz-box-shadow: 0 4px 4px -4px rgba(0, 0, 0, 0.7);-webkit-box-shadow: 0 4px 6px -5px // rgba(0, 0, 0, 0.8);\"><tr><td align=\"center\"><img alt=\"alt\" // src=\"images/logo.png\"></td><td align=\"left\">CMC LTD,New Delhi,Near Kohat Enclave Metro // Station</td></tr><tr><td> <p>Grettings, Thanks for registering // at CMC Delhi. We wish you a prosperous learning.If you any query click on this link <a // href=\"www.cmcdelhi.com\">Link</a></p></td></tr></table></body></html>"); email.setHtmlMsg( "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Insert title here</title></head><body>" + "<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\" style=\"border-collapse:collapse;margin:0;padding:0;background-color:#f2f2f2;height:100%!important;width:100%!important\"><tbody><tr><td align=\"center\" valign=\"top\" style=\"margin:0;padding:0;border-top:5px none #aaaaaa;height:100%!important;width:100%!important\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse\"><tbody>" + "<tr><td align=\"center\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: collapse; background-color: #ffffff; border-top: 0; border-bottom: 0\"><tbody><tr><td align=\"center\" valign=\"top\">" + "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\"style=\"border-collapse: collapse\"><tbody> <tr><td valign=\"top\" style=\"padding-top: 10px; padding-bottom: 10px\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: collapse\">" + "<tbody><tr><td valign=\"top\" style=\"padding: 9px\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"width=\"100%\" style=\"border-collapse: collapse\"><tbody><tr><td valign=\"top\" style=\"padding: 9px\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\"><tbody><tr><td valign=\"top\"><ahref=\"http://www.cmcdelhi.com/\" " + "title=\"\" style=\"word-wrap: break-word\" target=\"_blank\"><img alt=\"\" src=\"https://ci6.googleusercontent.com/proxy/RuvteIJkgNFYdxI6145X-lK4685AcOQxFui4iZxVKwtCz-hegVDIxdtSQ5PaGoE4fLQ_CR3uYlTuRNK8beuUu2loSM5gODacK1JsUqlEZ2lW2plIlZyyKfBPpqg6wpNywbTmDYca7UhlSa20h1k82LH1zIrVEMkqneme9Q=s0-d-e1-ft#http://gallery.mailchimp.com/38e8f39f127b52b8859e52f7c/images/4ea87a8b-6945-477c-904b-bbce8bf80a91.jpg\" width=\"116\" style=\"max-width: 116px; border: 0; outline: none; text-decoration: none; vertical-align: bottom\"></a></td></tr></tbody></table><table align=\"right\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"176\"style=\"border-collapse: collapse\"><tbody><tr><td valign=\"top\" style=\"font-family: Georgia, Times, 'Times New Roman', serif; font-size: 9px; font-style: normal; text-align: center; color: #606060; line-height: 150%\"><spanstyle=\"color: #000000; font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 16.003000259399414px; text-align: -webkit-center\">8,Vaishali Enclave,Main Metro Road, </span><br style=\"font-size: small; color: #000000; font-family: arial, helvetica, clean, sans-serif; line-height: 16.003000259399414px; text-align: -webkit-center\">" + "<span style=\"color: #000000; font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 16.003000259399414px; text-align: -webkit-center\">PitamPura,(Opp. Metro Pillar No. 351), New Delhi-110034,</span><br style=\"font-size: small; color: #000000; font-family: arial, helvetica, clean, sans-serif; line-height: 16.003000259399414px; text-align: -webkit-center\"><span style=\"color: #000000; font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 16.003000259399414px; text-align: -webkit-center\">India</span></td></tr></tbody> </table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr>" + "<tr><td align=\"center\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse;background-color:#ffffff;border-top:0;border-bottom:0\"><tbody><tr><td align=\"center\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"border-collapse:collapse\"><tbody><tr><td valign=\"top\" style=\"padding-top:10px;padding-bottom:10px\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse\"><tbody><tr><td valign=\"top\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"border-collapse:collapse\"><tbody><tr> <td valign=\"top\" style=\"padding:9px 18px;font-size:9px;color:#606060;font-family:Helvetica;line-height:150%;text-align:left\">" + "<h1 style=\"margin:0;padding:0;display:block;font-family:Helvetica;font-size:32px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:-1px;text-align:left;color:#606060!important\">Greetings From CMC Delhi</h1><h3 style=\"margin:0;padding:0;display:block;font-family:Helvetica;font-size:14px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:-.5px;text-align:left;color:#606060!important\">Registration Confirmation Email</h3><p style=\"margin:1em 0;padding:0;color:#606060;font-family:Helvetica;font-size:15px;line-height:150%;text-align:left\">Thanks for registering at CMC Delhi.This is system generated mail confirming your registration for course #####.Wishing you a prosperous learning.<br>Get your payment details here <a href=\"<a href=\"http://www.cmcdelhi.com\" target=\"_blank\">www.cmcdelhi.com</a>\"</p>" + "<p style=\"margin:1em 0;padding:0;color:#606060;font-family:Helvetica;font-size:15px;line-height:150%;text-align:left\">Need inspiration for your design? <a href=\"http://inspiration.mailchimp.com\" style=\"word-wrap:break-word;color:#6dc6dd;font-weight:normal;text-decoration:underline\" target=\"_blank\">Here�s what other MailChimp users are doing.</a></p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr>" + "<tr><td align=\"center\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse;background-color:#f2f2f2;border-top:0;border-bottom:0\"><tbody><tr><td align=\"center\" valign=\"top\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"border-collapse:collapse\"><tbody><tr><td valign=\"top\" style=\"padding-top:10px;padding-bottom:10px\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse\"><tbody><tr><td valign=\"top\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"border-collapse:collapse\"><tbody><tr>" + "<td valign=\"top\" style=\"padding-top:9px;padding-right:18px;padding-bottom:9px;padding-left:18px;color:#606060;font-family:Helvetica;font-size:11px;line-height:125%;text-align:left\"><em>Copyright � *|####YEAR#####|* CMC Delhi, All rights reserved.</em><br><br><strong>Our address :</strong><br><span style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">8,Vaishali Enclave,Main Metro Road, </span><br style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\"><span style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">" + "Pitam Pura,(Opp. Metro Pillar No. 351), New Delhi-110034,</span><br style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\"><span style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">India</span><br><strong style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">For Corporate Queries/College Tie-ups : Ashish Arora (09810324822) </strong><br style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">" + "<strong style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">For Student Queries: </strong><span style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">Ms. Sabia Rais / Ms. Priyanka:09313877528, 01165905335 & 65655335</span><br><strong style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">E-mail:</strong><a href=\"mailto:[email protected]\" style=\"color:blue;text-decoration:none;font-weight:bold;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center;word-wrap:break-word\" target=\"_blank\">" + "[email protected]</a><span style=\"color:#000000;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center\">/</span><a href=\"mailto:[email protected]\" style=\"color:blue;text-decoration:none;font-weight:bold;font-family:arial,helvetica,clean,sans-serif;font-size:small;line-height:16.003000259399414px;text-align:-webkit-center;word-wrap:break-word\" target=\"_blank\">ashis<wbr>[email protected]</a><br> </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr>" + "</tbody></table></body></html>"); // /Email Attachment // EmailAttachment attachment = new EmailAttachment(); // attachment.setPath("/home/guffy/Pictures/fggsa.jpg"); // attachment.setDisposition(EmailAttachment.ATTACHMENT); // attachment.setDescription("Picture of JMosque"); // attachment.setName("Mousque"); // email.attach(attachment); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // adding up the recivers for (String em : emailids) { // email.addTo("*****@*****.**"); email.addTo(em); } email.send(); return true; } catch (EmailException e) { Log.e("Email Exception : " + e.getMessage()); } catch (Exception e) { Log.e("Exception : " + e.getMessage()); } return false; }
@Signature public PHtmlEmail setCc(List<InternetAddress> addresses) throws EmailException { htmlEmail.setCc(addresses); return this; }
@Signature public PHtmlEmail setSubject(String subject) { htmlEmail.setSubject(subject); return this; }
@Signature public PHtmlEmail setCharset(String charset) { htmlEmail.setCharset(charset); return this; }
@Signature public PHtmlEmail setMessage(String value) throws EmailException { htmlEmail.setMsg(value); return this; }
public static void sendPromocao(Cotacao cotacao) { HtmlEmail email = new HtmlEmail(); try { email.setHostName("mail.gentec.inf.br"); email.setSmtpPort(587); email.setAuthentication("*****@*****.**", "123456"); email.addTo("*****@*****.**"); email.setFrom("*****@*****.**", "Pedido de Cota\347\343o"); email.setCharset("ISO-8859-1"); email.setSubject("Gentec IT"); email.setHtmlMsg( (new StringBuilder("<html><body><h1> Empresa: ")) .append(cotacao.getNomeEmpresa()) .append("</h1>") .append("<br/>") .append("<div>") .append("Nome de Cliente: ") .append(cotacao.getNomeCliente()) .append("<br/>") .append("CNPJ: ") .append(cotacao.getNumeroCnpj()) .append("<br/>") .append("Telefone: ") .append(cotacao.getNumeroTelefone()) .append("<br/>") .append("E-mail: ") .append(cotacao.getEmail()) .append("<br/>") .append("Observa\347\365es: ") .append(cotacao.getObservacoes()) .append("<br/>") .append("</div>") .append("</body>") .append("</html>") .toString()); email.setTextMsg("Seu servidor de e-mail n\343o suporta mensagem HTML"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
@Signature public PHtmlEmail setFrom(String email) throws EmailException { htmlEmail.setFrom(email); return this; }