RRRRHHHH_Code
6a5d4dad58d39bd2f78b516a2e2062472716eeef
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
package businessLogic; import java.security.Security; import java.util.Date; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import com.sun.mail.smtp.SMTPTransport; public class MailManager { private String user = "ruralhousesrh"; private String password = "RHRHRHRHRH"; private static MailManager mm = null; public static MailManager getInstance() { if (mm == null) return new MailManager(); else return mm; } public void Send( String recipientEmail, String title, String message) throws AddressException, MessagingException { Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; Properties props = System.getProperties(); props.setProperty("mail.smtps.host", "smtp.gmail.com"); props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY); props.setProperty("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.smtp.port", "465"); props.setProperty("mail.smtp.socketFactory.port", "465"); props.setProperty("mail.smtps.auth", "true"); props.put("mail.smtps.quitwait", "false"); Session session = Session.getInstance(props, null); // -- Create a new message -- final MimeMessage msg = new MimeMessage(session); // -- Set the FROM and TO fields -- msg.setFrom(new InternetAddress(user + "@gmail.com")); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail, false)); msg.setSubject(title); msg.setText(message, "utf-8"); msg.setSentDate(new Date()); SMTPTransport t = (SMTPTransport)session.getTransport("smtps"); t.connect("smtp.gmail.com", user, password); t.sendMessage(msg, msg.getAllRecipients()); t.close(); } } |
Commits for RRRRHHHH_CoderuralHouses/src/businessLogic/MailManager.java
Revision | Author | Commited | Message |
---|---|---|---|
6a5d4d ... | camjan | Sun 17 May, 2015 20:35:45 +0000 | Booking confirmation and e-mail service added. Some bugs to be solved. |