dcsimg
How to configur SMTP server for send Email
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rania_gferrag
Posted On:   Friday, May 9, 2003 07:03 AM

Hi Every one, I want to know what is the configuration that I must do with my SMTP so that I can send email from my program Java ? I have windows XP, and there smtp by default, I test my program to send email, but it doesn’t work, I get this error when sending email Error while sending the Mail and the exception is : javax.mail.SendFailedException: Sending failed; nested exception is : class javax.mail.MessagingException : Could not connect to SMTP host" 192.168.1.104, port : 25 Please if you have any suggestion or help it’s will be very welcome Thanks in advance. Best Regards, Here is m   More>>

Hi Every one,



I want to know what is the configuration that I must do with my SMTP so that I can send email from my program Java ?

I have windows XP, and there smtp by default, I test my program to send email, but it doesn’t work, I get this error when sending email


Error while sending the Mail and the exception is :

javax.mail.SendFailedException: Sending failed;
nested exception is :

class javax.mail.MessagingException : Could not connect to SMTP host" 192.168.1.104, port : 25


Please if you have any suggestion or help it’s will be very welcome


Thanks in advance.



Best Regards,




Here is my code :

import java.io.IOException;

import java.io.PrintWriter;

import java.util.Properties;

import javax.mail.*;

import javax.mail.internet.*;

import javax.naming.Context;

import javax.naming.InitialContext;

public class MailTest

{

String mailHost = "192.168.1.104";

String to = "rania@yahoo.com";

String from = "sender@hotmail.com";

String subject = "This is Test Mail *******";

String body = " this just test from my program

java";
Provider provider;

public MailTest()

{

try

{


Properties props = System.getProperties();


props.put("mail.smtp.host", mailHost);


//Authenticator auth = new Authenticator();



//props.put("mail.smtp.auth", "true");



Session session = Session.getInstance(props,null);


Message message = new MimeMessage(session);


message.setFrom(new InternetAddress(from));


message.setRecipients(Message.RecipientType.TO,new InternetAddress[]{new InternetAddress(to)});


message.setSubject(subject);


message.setContent(body, "text/plain");


Transport.send(message);
System.out.println("Mail has been Sent");


}
catch(MessagingException me)
{
System.out.println("2. Error While Sending the Mail and the exception is : " + me.toString());


}
}

public static void main(String arg[])
{
new MailTest();


}
}

   <<Less

Re: How to configur SMTP server for send Email

Posted By:   shishir_mishra  
Posted On:   Monday, June 16, 2003 05:11 AM

you are getting this kind of message because
1.that is not a smtp id.
2.you dont have permission to access that server.
what happens when you request to any smtp server for mailing first it will check weather ur a auth. user or not
if not u may get this kind of message.
here in u r code every thing is proper i think that smtp is not proper.pl check and try.

Re: How to configur SMTP server for send Email

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, May 9, 2003 07:31 AM

Can you manually telnet to port 25 at that host (192.168.1.104) and get a response prompt?


Also once you do get that working, you may have a problem because given your "to" and "from" addresses, your SMTP server should reject your message as an attempt to relay spam. Ordinarily either the sender or recipient is identified as somehow connected locally with the organization running the SMTP server, to prevent spam relaying.

About | Sitemap | Contact