*
The moose likes Other JSE/JEE APIs and the fly likes at the time automail generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "at the time automail generation " Watch "at the time automail generation " New topic
Author

at the time automail generation

ramesh kothakonda
Ranch Hand

Joined: Feb 14, 2006
Posts: 40
Sir ,
I am sending the automailjeneration java code. it is giving an exception

Hi javarancher,
I am getting below error at the time of auto mail geneation.If you solve this problem i wil be thank full to you.I am also sending the source code of my java file
================================================

i am in catch block::
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: smtpout.s
ecureserver.net, port: 80
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at sendmail3.send(sendmail3.java:27)
at sendmail3.main(sendmail3.java:38)
thanking you sir
k.ramesh
===========================================

import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class sendmail3 {
public static void send(String smtpHost, int smtpPort,
String from, String to,
String subject, String content)
throws AddressException, MessagingException {
// Create a mail session
try{

java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", ""+smtpPort);
Session session = Session.getDefaultInstance(props, null);

// Construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
msg.setText(content);

// Send the message
Transport.send(msg);
}
catch(Exception e)
{
System.out.println("i am in catch block::");
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
// Send a test message
send("smtpout.secureserver.net",80, "praveen@dwebtech.com", "ramesh.kothakonda@gmail.com",
"subject line-------", "this is body of mail --->How about at 7?");
}
}


The object oriented way of becoming "RICH" is by INHERITANCE<br />Whoever said money can't buy happiness, didn't know where to shop.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41066
    
  43
Could not connect to SMTP host

Looks like a connection problem. Are you certain that there is nothing between your code and that server that is blocking it?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: at the time automail generation
 
Similar Threads
japanese character as junk
simple javamail example getting error
Give me solution to send mail
Need Help in creating a Java Mailer
Javamail error