aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes JavaMail Error... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "JavaMail Error..." Watch "JavaMail Error..." New topic
Author

JavaMail Error...

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

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.



Could you guys let me where's it going wrong!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
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?


Ping & DNS - my free Android networking tools app
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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:


Is there any solution to this issue?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Unfortunately i don't administer the server. Is there a workaround?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Either make sure you only attempt to send emails from addresses the server is configured to allow or speak to your server administrator.
Paul Beckett
Ranch Hand

Joined: Jun 14, 2008
Posts: 96
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.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
That user name password thing made my code work! Thanks all!

Can this code be made to run on UNIX (Sun Solaris)? Or does it need a different concept! I was reading something about MAILX thing! Would that work?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
My mail code was sending mails fine till an hour ago... When I ran the code with two or three addresses I see that....


And the mail is not sent! Could you please let me know what could be the problem?
 
 
subject: JavaMail Error...