I am trying to send an e-mail using JavaMail API. But the thing is I can send it to my own Mail ID. But when I try my friends e-mail id i get an error message. I am putting his SMTP address and his e-mail address but i get an error message.
A quick lookup of SINCHNMBX001.TechMahindra.com indicates that the server can't be found (just like the error message says). Are you sure that's a publicly accessible mail server?
Well its my company's exchange server! So it could be private! But is there any way to send overcome this issue? When i put in my exchange server in the code i get the error message:
An SMTP 550 message is caused by server configuation - someone has deliberately configured a server to prevent relaying messages from domains not supported by the server. If this is a server you administer you should be able to fix it.
The problem here is more than likely to be authentication related. To send to an external email address you often need to authenticate your request.
When I hit similar problems a while ago, the way I authenticated (there may be other ways) was to add a property to the request.
You probably have something like:
Properties prop = new Properties();
prop.put("mail.smtp.host",host);
For authentication you also need to add:
prop.put("mail.smtp.auth","true");
Then when you use the Transport to send the message use the method:
Transport trans = session.getTransport(transportType);
...
trans.connect(host,user,password);
trans.sendMessage(msg,msg.getAllRecipients());
Another option for my org was to configure the email server to allow relay without authentication from selected hosts. Thats a question for your server admins.