Click here to Skip to main content
       

Java

 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 20 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid

You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Regarding Maven and Jenkins PinmembersivaKrishna joga3 Jan '13 - 0:23 
GeneralRe: Regarding Maven and Jenkins PinmvpRichard MacCutchan3 Jan '13 - 1:06 
GeneralRe: Regarding Maven and Jenkins PinmembersivaKrishna joga3 Jan '13 - 1:13 
I didnt ask or request anyone to do research for me.
I just meant in the post to share the info here if anyone knows it already.
If you dont know , then please stop answering to this thread.

Thank you.
GeneralRe: Regarding Maven and Jenkins PinmvpRichard MacCutchan3 Jan '13 - 1:58 
GeneralRe: Regarding Maven and Jenkins PinmembersivaKrishna joga3 Jan '13 - 2:16 
AnswerRe: Regarding Maven and Jenkins PinmemberApril Fans3 Jan '13 - 15:39 
Questionjava TLS Sending Email Pinmemberrenishkhunt2 Jan '13 - 18:52 
import javax.mail.*;
import javax.mail.Message;
import java.util.*;
import javax.mail.internet.*;
 
public class Sendemail {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
            final String username="username";
            final String password="password";
            Properties prop=new Properties();
            prop.put("mail.smtp.auth", "true");
            prop.put("mail.smtp.host", "smtp.gmail.com");
            prop.put("mail.smtp.port", "587");
            prop.put("mail.smtp.starttls.enable", "true");
        
            Session session = Session.getDefaultInstance(prop,
		  new javax.mail.Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username, password);
			}
		  });
          try {
 
			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("myemail@gmail.com"));
			message.setRecipients(Message.RecipientType.TO,
				InternetAddress.parse("receiveremail@gmail.com"));
			message.setSubject("Testing Subject");
			message.setText("Dear Mail Crawler,sNo spam to my email, please!");
                       
			Transport.send(message);
 
			System.out.println("Done");
 
		} catch (MessagingException e) {
			e.printStackTrace();
		}
            
    }
}
 

 

Please Help Someone..
    I have Exception On this code
 
javax.mail.MessagingException: 502 5.5.1 Unrecognized command. nw9sm29708787pbb.42
 
	at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2080)
	at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1910)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:652)
	at javax.mail.Service.connect(Service.java:317)
	at javax.mail.Service.connect(Service.java:176)
	at javax.mail.Service.connect(Service.java:125)
	at javax.mail.Transport.send0(Transport.java:194)
	at javax.mail.Transport.send(Transport.java:124)
	at sendemail.Sendemail.main(Sendemail.java:44)
 


AnswerRe: java TLS Sending Email PinmemberPhat (Phillip) H. VU2 Jan '13 - 22:08 
GeneralRe: java TLS Sending Email Pinmemberrenishkhunt2 Jan '13 - 23:26 
GeneralRe: java TLS Sending Email [modified] PinmemberPhat (Phillip) H. VU3 Jan '13 - 0:12