Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JavaMail - 554 Relay rejected for policy reasons.

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I'm getting the following error "554 Relay rejected for policy reasons" when sending emails to an address outside of my company's domain (i.e. bell.com):
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 554 Relay rejected for policy reasons.
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at com.canopyint.component.interop.smtp.EmailHelper.sendmail(EmailHelper
.java:149)
at com.canopyint.component.interop.smtp.EmailHelper.main(EmailHelper.jav
a:201)
.
So, I can't send emails to hotmail.com or yahoo.com addresses. The mail server I'm using is Lotus Domino 5.0.8. I'm supplying the username and password when creating the session object but an not getting anywhere.
Here's my code:
Properties props = new Properties();
props.put( "mail.transport.protocol", strProtocol);
props.put( "mail.smtp.host", strHost );
props.put( "mail.user", getProperty("mail.username"));
props.put( "mail.password", getProperty("mail.password"));

System.out.println("Creating session...");
Session session = Session.getDefaultInstance(props, ea);
System.out.println("Created session...");
// Construct a MimeMessage
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress( EmailHelper.returnDefault(mail,"from") ) );
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(EmailHelper.returnDefault(mail,"to"), false));
// -- set a CC: or BCC:
String cc = (String) mail.get("cc");
String bcc = (String) mail.get("bcc");
if (cc != null && (!cc.trim().equals(""))) msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc, false));
if (bcc != null && (!bcc.trim().equals(""))) msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(bcc, false));
msg.setSubject(EmailHelper.returnDefault(mail,"subject"));
msg.setSentDate(new Date());
msg.setText(EmailHelper.returnDefault(mail,"body"));
System.out.println("Sending msg...");
// Send the message.
Transport.send(msg);

Thanks in advance for your assistance.
reply
    Bookmark Topic Watch Topic
  • New Topic