Reputation: 405
I am facing some unknown type error, my code for sending the mail is as below
String mail_smtp_host=directoryPath("mail_smtp_host");
final String mail_host_username=directoryPath("mail_host_username");
final String mail_host_password=directoryPath("mail_host_password");
String mail_smtp_port=directoryPath("mail_smtp_port");
String set_from_emailid=directoryPath("set_from_emailid");
String set_from_emailid3=directoryPath("set_from_emailid3");
String set_from_emailid4=directoryPath("set_from_emailid4");
this all mail i am reading from property file
Properties props = new Properties();
props.put("mail.smtp.host", mail_smtp_host);
props.put("mail.smtp.socketFactory.port", "25");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", mail_smtp_port);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mail_host_username,mail_host_password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(mail_host_username));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(checkemail));
final String mail=""+set_from_emailid+","+set_from_emailid4+","+set_from_emailid3+"";
message.addRecipients(Message.RecipientType.BCC,
InternetAddress.parse(mail));
Here i am setting multiple BCC mail id
mess = "Hello"
message.setContent(mess, "text/html;charset=utf-8");
Transport.send(message);
It works in my local machine and mail is sent to the respect in BCC but as soon as deploy on ma test server it shows following error.
javax.mail.SendFailedException: Invalid Addresses; nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 501 5.5.2 RCPT TO syntax error
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584
enable to find the issue. please help
Thanks
Upvotes: 2
Views: 11101
Reputation: 29971
See this list of common JavaMail mistakes.
Turn on JavaMail session debugging and post the protocol trace so we can see exactly what the server is complaining about.
Most likely there's something wrong with one of the addresses you're using.
Upvotes: 1