on 07-17-2006 7:38 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
You need to configure your mail server properly so that mails go through it with proper authentications
regards,
Sujesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.