Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaMail Error...

 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Somnath Mallick
Ranch Hand
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately i don't administer the server. Is there a workaround?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 482
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic