Reputation: 989
im facing some problems with Lotus server. The guy that is in charge of the server is telling me that the configuration is ok, but i cant send mail with html body with his lotus server.
The error i get is : “554 Relay rejected for policy reasons.”
When i tried on my pc, i used smpt.gmail.com and worked like a champ. So i believe is not a code problem and the issue is with the server configuration.
Is there a problem with javaMail and Lotus? is it a common issue? (in one blog some guy was saying that it can not be possible to send html but i cant believe that)
My code just in case,
public void sendEmail(String toEmailAddr, String subject, String issue) {
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
Session mailSession = Session.getDefaultInstance(props);
Message simpleMessage = new MimeMessage(mailSession);
InternetAddress toAddress = null;
InternetAddress toAddress2[] = null;
Transport t = null ;
try {
Multipart mp = new MimeMultipart();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(issue, "text/html");
mp.addBodyPart(htmlPart);
simpleMessage.setContent(mp);
} catch (MessagingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
toAddress = new InternetAddress(toEmailAddr);
toAddress2 = new InternetAddress [1];
toAddress2[0] = toAddress;
} catch (AddressException e) {
// TODO LOG
e.printStackTrace();
}
try {
simpleMessage.setRecipients(RecipientType.TO, toAddress2);
simpleMessage.setSubject(subject);
t = mailSession.getTransport("smtp");
if(userPwd==null)
userPwd = "";
t.connect(host, userName, userPwd);
t.sendMessage(simpleMessage, simpleMessage.getAllRecipients());
} catch (MessagingException e) {
e.printStackTrace();
// TODO LOG
}finally{
try {
t.close();
} catch (MessagingException e) {
// TODO LOG
}
}
}
Regards.
Upvotes: 0
Views: 4289
Reputation: 2568
May require Secure Connection(SSL), Use the following properties to connect mail server supporting smtp protocol:
properties.put("mail.smtp.socketFactory.port", "SMTP_PORT");
properties.put("mail.smtp.host", "SMTP_SERVER_HOST_NAME_OR_IP");
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.socketFactory.fallback", "false");
Upvotes: 0
Reputation: 3
i had the same problem and solved it. The FROM part was "[email protected]" and changed it to "[email protected]" and it began to send
Upvotes: 0
Reputation: 21709
SMTP on the Domino server has most likely been set up to only allow relay by certain hosts - therefore the error message 554 Relay rejected for policy reasons
.
You should talk to the admin and have him change the configuration to allow relay by other hosts. This is configured in a configuration document in the Router/SMTP -> Restrictions and Controls -> SMTP Inbound Controls section. More information on SMTP inbound relay controls is available here: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.help.domino.admin.doc%2FDOC%2FH_SETTING_INBOUND_RELAY_CONTROLS_STEPS.html
Upvotes: 3