haifa tl

Greenhorn
+ Follow
since Apr 14, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by haifa tl

Hello,

The account I am using is my yahoo mail account.
please explain more , I diden't get you
17 years ago
Hello,

I am looking for help : I developed a java code for sending an automatic email to users when they register.

My code is working with smtp.gmail.com but not with yahoo !!
can any body help me to fix the cause ?

here is my code

public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

response.setContentType("text/plain");
PrintWriter out = response.getWriter();

/**
* just for debug
*/

//String host = "smtp.jc.ae/email";
String d_email = "my-email@yahoo.com",
d_password = "pwd",
d_host = "smtp.mail.yahoo.com",
d_port = "465",
m_to = "email@yahoo.com",
m_subject = "Registration Confirmation ",
m_text = "You have been registered -- If you want to receive updates via email or sms please Login";


Properties props = new Properties();
props.put("mail.smtp.user", "my-email");
props.put("mail.smtp.host", d_host);
props.put("mail.smtp.port", d_port);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
//props.put("mail.smtp.debug", "true");
props.put("mail.smtp.socketFactory.port", d_port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

SecurityManager security = System.getSecurityManager();

try
{
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
//session.setDebug(true);

MimeMessage msg = new MimeMessage(session);
msg.setText(m_text);
msg.setSubject(m_subject);
msg.setFrom(new InternetAddress(d_email));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
Transport.send(msg);
}
catch (Exception mex)
{
mex.printStackTrace();
out.println(mex.getMessage());
out.println(stack2string(mex));
}
}
private class SMTPAuthenticator extends javax.mail.Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("my-email@yahoo.com", "pwd");
}
}

static public String stack2string(Exception e) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return "------\r\n" + sw.toString() + "------\r\n";
}
catch(Exception e2) {
return "bad stack2string";
}
}

And I am sure about mu username and password but when I run I always have this error:

Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException

please help
17 years ago
Hello,

I am looking for help : I developed a java code for sending an automatic email to users when they register.

My code is working with smtp.gmail.com but not with yahoo !!
can any body help me to fix the cause ?

here is my code

public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

response.setContentType("text/plain");
PrintWriter out = response.getWriter();

/**
* just for debug
*/

//String host = "smtp.jc.ae/email";
String d_email = "my-email@yahoo.com",
d_password = "pwd",
d_host = "smtp.mail.yahoo.com",
d_port = "465",
m_to = "email@yahoo.com",
m_subject = "Registration Confirmation ",
m_text = "You have been registered -- If you want to receive updates via email or sms please Login";


Properties props = new Properties();
props.put("mail.smtp.user", "my-email");
props.put("mail.smtp.host", d_host);
props.put("mail.smtp.port", d_port);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
//props.put("mail.smtp.debug", "true");
props.put("mail.smtp.socketFactory.port", d_port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

SecurityManager security = System.getSecurityManager();

try
{
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
//session.setDebug(true);

MimeMessage msg = new MimeMessage(session);
msg.setText(m_text);
msg.setSubject(m_subject);
msg.setFrom(new InternetAddress(d_email));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
Transport.send(msg);
}
catch (Exception mex)
{
mex.printStackTrace();
out.println(mex.getMessage());
out.println(stack2string(mex));
}
}
private class SMTPAuthenticator extends javax.mail.Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("my-email@yahoo.com", "pwd");
}
}

static public String stack2string(Exception e) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return "------\r\n" + sw.toString() + "------\r\n";
}
catch(Exception e2) {
return "bad stack2string";
}
}

And I am sure about mu username and password but when I run I always have this error:

Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException

please help
17 years ago