Hi everyone!
I have a program that send mail using JavaMail :
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class demo {
public static void main (String args[]) throws Exception {
String host = myMailHost;
String from = mailFrom;
String to = mailTo;
String userName = "userName";
String password = "password";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", 25);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.quitwait", "false");
Session session = Session.getDefaultInstance(props, new MyAuthenticator(userName, password));
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");
Transport.send(message);
}
}
class MyAuthenticator extends Authenticator
{
private String userName;
private String password;
MyAuthenticator()
{
super();
}
MyAuthenticator(String userName, String password)
{
super();
this.userName = userName;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(userName, password);
}
}
but I got an Exception :
com.sun.mail.smtp.SMTPSendFailedException: 554 Message does not conform to standards
The mail server use MDaemon, and i think that it worked properly.
Please let me know how to solve this, thanks !