Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- // Recipient's email ID needs to be mentioned.
- String to = "destinationemail@gmail.com";
- // Sender's email ID needs to be mentioned
- String from = "fromemail@gmail.com";
- final String username = "manishaspatil";//change accordingly
- final String password = "******";//change accordingly
- // Assuming you are sending email through relay.jangosmtp.net
- String host = "relay.jangosmtp.net";
- 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", "25");
- // Get the Session object.
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }
- });
Add Comment
Please, Sign In to add comment