Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SMTP relay works with Thunderbird but not with Javamail

843830Jul 27 2004 — edited Aug 2 2004
Hi all,
I'm really clueless now and decided to ask for help here in this forum.
I'm trying to send a mail via an SMTP server which needs a login.
I keep getting the error message
"javax.mail.SendFailedException: 554 <an_existing@mailaddress.de>: Relay access denied"

I read many postings in this forum which say that the smtp server's config is responsible.
But that cannot be because I'm able to send mails via the smtp-server when I use the mail client Mozilla-Thunderbird.
Thunderbird runs on the same computer as my java mail program does.

Does anyone know how this can be?

My first guess was that it must be an authentication problem.
But the following lines work well.
Transport transport = session.getTransport("smtp");
transport.connect(host, user, pwd);
Maybe I should use the other way of authentication.
But unfortunately the following code leads to an authentication failure (DEBUG SMTP RCVD: 535 Error: authentication failed).
Properties props = System.getProperties();
props.put("mail.MailTransport.protocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth","true");
SmtpAuthenticator auth = new SmtpAuthenticator(user, pwd);
Session session = Session.getDefaultInstance(props, auth);		
with
	private class SmtpAuthenticator extends Authenticator {
		private String user = null;
		private String pwd  = null;

		public SmtpAuthenticator(String user, String pwd) {
			this.user = user;
			this.pwd = pwd;
		}

		protected PasswordAuthentication getPasswordAuthentication() {
			return new PasswordAuthentication(this.user, this.pwd);
		}
	}
Any hints are greatly appreciated.
Thanks in advance,

Stefan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 30 2004
Added on Jul 27 2004
11 comments
1,167 views