Hi ..
I am new to JavaMail...
http://209.85.175.104/search?q=cache:h2HRteCAXKoJ:www.zukowski.net/WebTech-JavaMail.ppt+javamail+faq&hl=en&ct=clnk&cd=4&gl=in
i am trying to run this code ...from this url..
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample
{
public static void main (String args[]) throws Exception
{
String host = args[0];
String from = args[1];
String to = args[2];
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host",host );
// Get session
Session session = Session.getInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
}
}
It gives Error..
C:\Program Files\Java\jdk1.6.0_02\bin>java MailExample smtp.gmail.com xyz@gmail.
com pqr@gmail.com
Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0
Must issue a STARTTLS command first. 28sm12530978wfd.4
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
515)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1054)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:634)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at MailExample.main(MailExample.java:26)
How to run this??
plz help me??