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