cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Mail

Former Member
0 Kudos

How can I send mail(not using Web services)from Web dynpro-java.I tried with simple java code(java Mail API) but I am getting javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Fahad,

Can you give a bit more detail about the problem like pasting code snippet here??

A quick check: are you using Session.getDefaultInstance(props, null);, try using Session.getInstance instead.

Regards,

Mausam

Former Member
0 Kudos

First I tried with Simple console application as follows:

import javax.mail.*;

import java.util.*;

import javax.mail.internet.*;

class Mail

{

public static void main(String s[])

{

Session ses=null;

Message msg=null;

try

{

Properties p=System.getProperties();

//Properties p=new Properties();

p.put("mail.smtp.host","host");

p.put("mail.transport.protocol","smtp");

p.put("mail.smtp.auth","false");

p.put ("mail.smtp.port", "25");

boolean sessionDebug=true;

Authenticator a=new Auth("usr","pwde");

ses=Session.getInstance(p,a);

ses.setDebug(sessionDebug);

msg=new MimeMessage(ses);

msg.setFrom(new InternetAddress("fahadibm@gmail.com"));

(Message.RecipientType.TO,address[0]); msg.setRecipient(Message.RecipientType.TO,new InternetAddress("imran@abc.com"));

msg.setSubject("Test");

msg.setSentDate(new Date());

msg.setText("This is a Test");

}

catch(Exception e)

{

System.out.println("E1"+e);

}

try

{

Transport.send(msg);

}

catch(Exception e)

{

System.out.println("Exception is"+e);

}

}

}

class Auth extends Authenticator

{

String name;

String pwd;

public Auth(String name,String pwd)

{

this.name=name;

this.pwd=pwd;

}

public PasswordAuthentication getAuthenticate()

{

return new PasswordAuthentication(name,pwd);

}

}

But when I tried this I am getting

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 unable to realy

imran@abc.com

But I gave valid mailId, username and password

Former Member
0 Kudos

Hi,

Just a thought...typically, mail servers for an organization are configured to allow mail from within the organization to be sent to other internal addresses within the organization, or to addresses external to the organization. It will also typically allow mail coming from an address external to an organization to be sent to internal addresses within the orgnaization. What it will typically not allow is mail coming from an address external to the organization to be sent (relayed) to another address also external to the organization. The configuration of the mail server determines whether such relaying is allowed, and which addresses are considered internal vs. external.

So check if your mail server has this configuration.

Also check if you can send a mail from your internal ID to any external ID.

Regards,

Satyajit.

Former Member
0 Kudos

Thanks for the quick reply.I will check it

Former Member
0 Kudos

You need to configure your mail server properly so that mails go through it with proper authentications

regards,

Sujesh