Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problems sending mail in differents instances

Hi everyone!

I have a strange problem when my Portal application (JSPDynpage) try to send mail using the exchange server - note: this server works fine when I send a mail by collaboration-

In DEV instance, the same application works fine and the mails are sending without problems, but... in QA this exceptions occurs:

Sending failed; nested exception is: javax.mail.AuthenticationFailedException



It is so strange, because, is the same Portal App, the same Exchange server, and the same users (from, to), the only difference are the instances:

DEV

/

QA

Any Idea??

any suggest??

this is the code:

try{

  Properties props = System.getProperties();

  props.put("mail.smtp.host", "x.x.x.x");
  props.put("mail.smtp.auth", "true");

  Session session = Session.getDefaultInstance(props, null);
  com.sap.security.api.IUser User = UMFactory.getUserFactory().getUserByLogonID(iuser.getId());
  MimeMessage message = new MimeMessage(session);
  message.setFrom(new InternetAddress(User.getEmail()));
  message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAdmin));
  message.setSubject("InscripciĆ³n a Curso ");

  message.setText("blablabla");

  Transport.send( message );
}
  catch(Exception ex){
	error = "Error enviando mail : "+ex.getMessage();
}

thanks in advance.

it is very urgent, I promise points

Leslie.-

Former Member replied

Hi Leslie,

Transport.send( message );

can only use with no authentification. Otherwise you need this code :

if(auth)
{
    Transport transport = session.getTransport("smtp");
    transport.connect(smtpHost,smtpLogin,smtpPassword); 
    message.saveChanges();
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  }
else
    Transport.send(message);

Best regards,

Mathieu

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question