aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes javax.mail.SendFailedException:Sending Failed; when i send other domain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "javax.mail.SendFailedException:Sending Failed; when i send other domain" Watch "javax.mail.SendFailedException:Sending Failed; when i send other domain" New topic
Author

javax.mail.SendFailedException:Sending Failed; when i send other domain

vinoth sathiya
Ranch Hand

Joined: Sep 20, 2011
Posts: 36
Hi,

I'm using java api mail. i tested gmail. its woring fine. and also am testing other domain server(testserver.com). its working under same domain(testserver.com to testserver.com).but when i try to send from testserver.com domain server to other domain like gmail or hotmail or yahoo means it showing exection.

here is my code:

try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", "server2.testserver.com");
props.put("mail.debug", "true");
props.put("mail.smtp.user", "test@testserver.com");
props.put("mail.smtp.password", "test");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl", "true");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");


if (from != null && pword != null)
{
props.put("mail.smtp.auth", "true");
session = Session.getInstance(props,
new MyPasswordAuthenticator(from, pword));
}
else
{
session = Session.getDefaultInstance(props, null);
}
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));

InternetAddress toAddress[] = new InternetAddress[to.length];
for(int i = 0; i < to.length; i++)
{
toAddress[i] = new InternetAddress(to[i]);
}

message.setRecipients(javax.mail.Message.RecipientType.TO, toAddress);
message.setSubject(subject);
BodyPart bp1 = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
bp1.setText(messageBody);
multipart.addBodyPart(bp1);
bp1 = new MimeBodyPart();
javax.activation.DataSource source = new FileDataSource(ff);
bp1.setDataHandler(new DataHandler(source));
bp1.setFileName("fileName");
multipart.addBodyPart(bp1);
message.setContent(multipart);
Transport.send(message);
System.out.println("Sucessfully sent");
}
catch(Exception e)
{
System.out.println((new StringBuilder("this is the error: ")).append(e).toString());
return false;
}


//***************


when i try to send gmail or anyother mail server means it showing below exception:

javax.mail.SendFailedException:Sending Failed;
nested exception is:
class javax.mail.MessagingException: Exception reading response;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

Any one please find the solution.

Thanks in advance,

Vinoth sathiya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  68
Does that other mail server support SSL connections?
vinoth sathiya
Ranch Hand

Joined: Sep 20, 2011
Posts: 36
Hi,

Thanks for reply.

May i know how to identify if that(testserver.com) domain server is support SSL connection or not.?

Is there any program for that?

Thanks in advance.

Vinoth.Sathiya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  68
Check the documentation of the host (if this is hosted somewhere) or ask the server admin.
vinoth sathiya
Ranch Hand

Joined: Sep 20, 2011
Posts: 36
Ulf Dittmer wrote:Check the documentation of the host (if this is hosted somewhere) or ask the server admin.


But they have configured in Outlook Express 2007 and make send and recieve other domain( gmail,yahoo,hotmail etc.,) also...

they said everything is configured correctly.

only problem when i use to send via smtp connection using our applications.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.mail.SendFailedException:Sending Failed; when i send other domain