List of utility methods to do Email Send
void | sendEmail(String toAddress, String subject, String message) send Email final String userName = "idesaniv@gmail.com"; final String password = "26577141"; String host = "smtp.gmail.com", port = "25"; Properties properties = new Properties(); properties.put("mail.transport.protocol", "smtp"); properties.put("mail.smtp.host", host); properties.put("mail.smtp.port", port); properties.put("mail.smtp.auth", "true"); ... |
void | sendMail(Properties props, String recipients[], String subject, String message, String from) Sends a mail to a list of recipents boolean debug = false; Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); Message msg = new MimeMessage(session); InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i < recipients.length; i++) { ... |
void | sendMail(Session session, Message message) send Mail Transport transport = session.getTransport(); transport.connect(user, password); transport.sendMessage(message, message.getAllRecipients()); |
void | sendMail(String filePathName, InternetAddress[] addresses, List
Use JavaMail to send the actual mail message to the provided addresses by default through localhost port 25. Session session = Session.getDefaultInstance(System.getProperties()); Multipart multipart = new MimeMultipart(); Message message = new MimeMessage(session); message.addRecipients(Message.RecipientType.TO, addresses); message.setSubject("Infomedia upload reports for " + filePathName); BodyPart messageBodyPart = new MimeBodyPart(); String bodyText = "\n"; ... |
void | sendMail(String host, int port, String username, String password, String recipients, String subject, String content, String from) send Mail Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", host); props.put("mail.smtp.port", port); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); ... |
void | sendMail(String smtpServer, String to, String from, String subject, String body) send Mail try { Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); Session session = Session.getDefaultInstance(props, null); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false)); msg.setSubject(subject); ... |
void | sendMail(String to, String from, String subject, String body, boolean bodyIsHTML) send Mail Properties props = new Properties(); props.put("mail.transport.protocol", "smtps"); props.put("mail.smtps.host", "smtp.gmail.com"); props.put("mail.smtps.port", 465); props.put("mail.smtps.auth", "true"); props.put("mail.smtps.quitwait", "false"); Session session = Session.getDefaultInstance(props); session.setDebug(true); ... |
void | sendMail(String toEmailId, String subject, String msgText, String from, String smtpServer, String userName, String password) send Mail Properties properties = new Properties(); properties.setProperty("mail.smtp.host", smtpServer); Session session = Session.getDefaultInstance(properties); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmailId)); message.setSubject(subject); message.setContent(msgText, "text/html; charset=utf-8"); ... |
void | sendMail(String vmName, String property, String emailId, boolean usageHigh) send Mail Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); String subjectHighUsage = vmName + ": has reached limit " + property + " usage"; String subjectNormalUsage = vmName + ": You are back to normal " + property + " usage"; String emailBodyHighUsage = "Hello," + "\n\n THIS IS AN AUTOGENRATED MAIL. PLEASE DO NOT REPLY TO THIS.\n" ... |
void | sendMessage(Message message) send Message try { Transport.send(message); } catch (MessagingException e) { throw new RuntimeException(e); |