Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

at the time automail generation

ramesh kothakonda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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, port: 80
at javax.mail.Transport.send0(
at javax.mail.Transport.send(
at sendmail3.send(
at sendmail3.main(
thanking you sir

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

java.util.Properties props = new java.util.Properties();
props.put("", 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));

// Send the message
catch(Exception e)
System.out.println("i am in catch block::");

public static void main(String[] args) throws Exception {
// Send a test message
send("",80, "", "",
"subject line-------", "this is body of mail --->How about at 7?");
Ulf Dittmer
Posts: 42968
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic