Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Could not connect to SMTP host: smtp.mail.yahoo.com, port: 25

843830Mar 19 2007 — edited Mar 19 2007
Hi,
I've been trying various way to resolve this error but cant seem to get it right. i noticed that i need a authenticator.
Not sure how it can be done can anyone help me to edit my program as well?
Meanwhile i heard that McAfee maybe also the cause of it but i cant cant seem to find where is
Virus scan console >> Access Protection >> Port Blocking tabe >> Rule >> check out check box for port 25 on my window xp.
May i know where to find the directory?
The only virus program im using is Norton Anti-Virus.
Can anyone help me with this? Really appreciate if it succeeds.


My program as follows:


package database;

import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;

public final class MailerBean extends Object implements Serializable {

/* Bean Properties */
private String to = null;
private String from = null;
private String subject = null;
private String message = null;
public static Properties props = null;
public static Session session = null;

static {
/* Setting Properties for STMP host */
props = System.getProperties();
props.put("mail.smtp.host", "smtp.mail.yahoo.com");


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


session = Session.getDefaultInstance(props, null);
}
/* Setter Methods */
public void setTo(String to) {
this.to = to;
}

public void setFrom(String from) {
this.from = from;
}

public void setSubject(String subject) {
this.subject = subject;
}

public void setMessage(String message) {
this.message = message;
}
/* Sends Email */
public void sendMail() throws Exception {
if(!this.everythingIsSet())
throw new Exception("Could not send email.");
try {
MimeMessage message = new MimeMessage(session);
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(this.to));
message.setFrom(new InternetAddress(this.from));
message.setSubject(this.subject);
message.setText(this.message);
Transport.send(message);
} catch (MessagingException e) {
throw new Exception(e.getMessage());
}
}

/* Checks whether all properties have been set or not */
private boolean everythingIsSet() {
if((this.to == null) || (this.from == null) ||
(this.subject == null) || (this.message == null))
return false;

if((this.to.indexOf("@") == -1) ||
(this.to.indexOf(".") == -1))
return false;

if((this.from.indexOf("@") == -1) ||
(this.from.indexOf(".") == -1))
return false;

return true;
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2007
Added on Mar 19 2007
1 comment
123 views