urgent!!!! Problem in sending mail through yahoo mail server
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Tuesday, August 28, 2001 10:36 PM

Hi I have a yahoo account and I want to send email through yahoo mail server using my java program. My program supports SMTP server authentication. But when I connect to the yahoo mail server(smtp.mail.yahoo.com) I got this error ..................................................................... javax.mail.MessagingException: 521 yahoo.com closing transmission channel. You must be pop-authenticated before you can use this smtp server, and you must use your yahoo mail address for the Sender/From field. ..................................................................... This is my program ...................................................   More>>

Hi

I have a yahoo account and I want to send email through yahoo mail server
using my java program. My program supports SMTP server authentication.

But when I connect to the yahoo mail server(smtp.mail.yahoo.com) I got this error


.....................................................................

javax.mail.MessagingException: 521 yahoo.com closing transmission channel. You
must be pop-authenticated before you can use this smtp server, and you must use
your yahoo mail address for the Sender/From field.

.....................................................................


This is my program

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


public class JavaMailUserAgent
{

Properties properties;
Session session;
Message message;


JavaMailUserAgent(String mailHost,String smtpUsername,String smtpPassword) throws Exception
{

properties=new Properties();
properties.put("mail.smtp.host",mailHost);

ServerAuthenticate auth=new ServerAuthenticate(smtpUsername,smtpPassword);

session=Session.getInstance(properties,auth);

message=new MimeMessage(session);


} //**********************************************************************end constructor


void sendMail(String messageFrom,String messageTo,String subject,String messageBody) throws Exception
{

properties.put("mail.from",messageFrom);

InternetAddress[] address={ new InternetAddress(messageTo) };


message.setFrom(new InternetAddress(messageFrom));

message.setRecipients(Message.RecipientType.TO,address);

message.setSubject(subject);

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


Transport transport=session.getTransport(address[0]);

transport.addConnectionListener(new ConnectionHandler());

transport.addTransportListener(new TransportHandler());

transport.connect();

transport.sendMessage(message,address);


} //*************************************************************************end function


}
//*************************************************************************************end
main


class ConnectionHandler extends ConnectionAdapter
{

public void opened(ConnectionEvent e)
{
System.out.println("connection opened");
}
public void disconnected(ConnectionEvent e)
{
System.out.println("connection disconnected");
}
public void closed(ConnectionEvent e)
{
System.out.println("connection closed");
}


}
//*************************************************************************************end
main


class TransportHandler extends TransportAdapter
{

public void messageDelivered(TransportAdapter e)
{
System.out.println("message delivered");
}
public void messageNotDelivered(TransportAdapter e)
{
System.out.println("message NOT delivered");
}
public void messagePartiallyDelivered(TransportAdapter e)
{
System.out.println("message partially delivered");
}


}
//*************************************************************************************end
main


class ServerAuthenticate extends Authenticator
{

String smtpUsername = null;
String smtpPassword = null;


public ServerAuthenticate(String username, String password)
{
smtpUsername = username;
smtpPassword = password;
}


protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(smtpUsername,smtpPassword);
}


}
//*************************************************************************************end
main


......................................................................


I use this code to call the program.

JavaMailUserAgent jmail=new JavaMailUserAgent("smtp.mail.yahoo.com","my_yahoo_username","my_yahoo_password");

jmail.sendMail("me@yahoo.com","someone@yahoo.com","test subject","test message");


..........................................................................



Could you pls tell me why do I get this error eventhough My program has server authentication.
Is this my program error.Please Helpl me what to do to correct this problem.


Please include a sample code


thanks for listening

sabu

   <<Less
About | Sitemap | Contact