Urgent!!!! Problem in sending mail through yahoo mail server

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("[email protected]","[email protected]","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

I have used the code below to send mail from yahoo account,but I got the error message like below,what I should configure in pop3 of yahoo account????
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);
public static void main(String str[])throws Exception
JavaMailUserAgent jmail=new
JavaMailUserAgent("smtp.mail.yahoo.com","[email protected]","passwordd");
jmail.sendMail("[email protected]","[email protected]","test subject","test message");
ERROR:
E:\mail\javamail\servlet>java ServerAuthenticate
connection opened
Exception in thread "main" javax.mail.MessagingException: 530 authentication req
uired - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:879)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:599)
at com.sun.mail.smtp.SMTPTransport.sendMessage(Compiled Code)
at JavaMailUserAgent.sendMail(JavaMailUserAgent.java:58)
at ServerAuthenticate.main(JavaMailUserAgent.java:131)
How Could I rectyfy the above error ?????
Regards,
Mahesh.

Similar Messages

  • Send email through Yahoo mail or Gmail with Java

    I have a java email program that can take a mail host name , port number and then send an email, but I don't want to use the mail host at work, I wonder if I can send email through my Yahoo Mail or Gmail account with Java, do they have any Java API that my program can log me in and send emails ? Any sample code available ? Thanks.
    Frank

    Thanks for reminding me, I did some search on "Yahoo" and "Gmail". For Yahoo someone posted some code that didn't work, for gmail, there seems to be a solution for sending email from command line. I wonder if I can send full fledged email : with CC, BCC, Attachment, Html email with images inside ...
    I've done it with a local mail host, but how to do it with Yahoo or Gmail ?
    Frank
    Have you read the JavaMail FAQ? Search for "Yahoo" and "Gmail".

  • Cannot send emails on Yahoo mail. It works okay with Safari. I set default to Yahoo but still cannot send

    Use MAC. Cannot send emails through Yahoo mail through Firefox but can send through Safari.
    Also issue with Facebook. Using Firefox cannot sign out of account. Can sign out when using Safari.

    Which security software (firewall, anti-virus) do you have?
    Boot the computer in Windows Safe Mode with network support (press F8 on the boot screen) as a test to see if that helps.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Cannot send email through yahoo on iPad 4, apple.smtp.mail.yahoo not available as of December 1, 2012

    I am unable to send emails through yahoo on my ipad 4 wifi, just starting over the weekend. My 3 other non-yahoo email accounts are working fine on my ipad. When I try to send an email from the yahoo account, I receive the message that the connection to the outgoing mail server "apple.smtp.mail.yahoo" failed. I can send email through yahoo just fine on the web and on my computer through Thunderbird.

    Yahoo's been having persistently random issues for months. You can try just waiting it out, or delete and readd your yahoo account. When my accounts were affected I just used webmail to access my yahoo accounts until it cleared up.
    Chances are it's all on their end and really all you can do is wait it out.

  • I am not able to send mails through Yahoo APP.It gives me an error msg :"the sender address has ben rejected by the server ".I tried adding username and password in the SMTP server settings,But those optiopns are greyed out.

    I am not able to send mails through Yahoo APP. It gives me an error msg :"the sender address has ben rejected by the server ".
    I tried adding username and password in the SMTP server settings,But those optiopns are greyed out.
    So, i am not able to enter anything in fields under SMTP server settings

    You probably have changing settings disabled in Restrictions.

  • TS3899 i-pad wont send or receive Yahoo mail.Mac computer does. All Apps OK. Wi-Fi is OK. i-cloud OK.G-Mail OK. Just Yahoo has the problem. Should I delete the account and set it up again? Will I loose contacts?

    Hello. I cannot send or receive Yahoo mails on my i-pad.  G-Mail is OK. All Apps are OK. Wi-Fi is OK. I-Cloud is OK. 3G is OK. All OK except Yahoo Mail. The message on i-pad is "cant receive/send mail. the connection to the server failed."  My Mac Computer is fine,mails sent and received. My i-pod is fine. Mails sent and received on both.. Only the i-pad has the problem. Should I delete the Yahoo account on the i-pad and set it up again? Will I loose anything in the i-pad? Help.

    Yahoo Mail has been having problems.
    iOS: Unable to send or receive email
    http://support.apple.com/kb/TS3899
    Can’t Send Emails on iPad – Troubleshooting Steps
    http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
    Setting up and troubleshooting Mail
    http://www.apple.com/support/ipad/assistant/mail/
    iPad Mail
    http://www.apple.com/support/ipad/mail/
    Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    Or this - Delete the account in Mail and then set it up again. Settings->Mail, Contacts, Calendars -> Accounts   Tap on the Account, then on the red button that says Remove Account.
     Cheers, Tom

  • Problem with sending and receiving e-mail through exchange [GMail]

    Hello I have problem with sending and receiving e-mail.
    all is well set, username and password are correct, the server set m.google.com. verification of data is about like stepping into a post and want to check the post office gives me an error message: Can not Get Mail. The connection to the server has failed
    I have this problem on my two iPhone

    http://www.zdnet.com/google-drops-exchange-activesync-support-for-free-email-acc ounts-7000008836/

  • Cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    Not sure about yahoo, but for gmail, I done the following:
    Set up using Exchange on iPhone, it'll keep prompting for password.  On PC use captcha option, log in to gmail account from PC after completingg captcha option, enter password on iPhone.
    See how that goes for gmail, let us know.
    Hopefully someone will have fix for yahoo.

  • Problem in sending messages using java mail api

    Hi All,
    I have a problem in sending messages via java mail api.
    MimeMessage message = new MimeMessage(session);
    String bodyContent = "ñSunJava";
    message.setText (bodyContent,"utf-8");using the above code its not possible for me to send the attachment. if i am using the below code means special characters like ñ gets removed or changed into some other characters.
    MimeBodyPart messagePart = new MimeBodyPart();
                messagePart.setText(bodyText);
                // Set the email attachment file
                MimeBodyPart attachmentPart = new MimeBodyPart();
                FileDataSource fileDataSource = new FileDataSource("C:/sunjava.txt") {
                    public String getContentType() {
                        return "application/octet-stream";
                attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                attachmentPart.setFileName(filename);
                Multipart multipart = new MimeMultipart();
                multipart.addBodyPart(messagePart);
                multipart.addBodyPart(attachmentPart);
                message.setContent(multipart);
                Transport.send(message);is there any way to send the file attachment with the body message without using MultiPart java class.

    Taken pretty much straight out of the Javamail examples the following works for me (mail read using Thunderbird)        // Define message
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            // Set the 'to' address
            for (int i = 0; i < to.length; i++)
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    // Set the 'cc' address
    for (int i = 0; i < cc.length; i++)
    message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
    // Set the 'bcc' address
    for (int i = 0; i < bcc.length; i++)
    message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
    message.setSubject("JavaMail With Attachment");
    // Create the message part
    BodyPart messageBodyPart = new MimeBodyPart();
    // Fill the message
    messageBodyPart.setText("Here's the file ñSunJava");
    // Create a Multipart
    Multipart multipart = new MimeMultipart();
    // Add part one
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    for (int count = 0; count < 5; count++)
    String filename = "hello" + count + ".txt";
    String fileContent = " ñSunJava - Now is the time for all good men to come to the aid of the party " + count + " \n";
    // Create another body part
    BodyPart attachementBodyPart = new MimeBodyPart();
    // Get the attachment
    DataSource source = new StringDataSource(fileContent, filename);
    // Set the data handler to this attachment
    attachementBodyPart.setDataHandler(new DataHandler(source));
    // Set the filename
    attachementBodyPart.setFileName(filename);
    // Add this part
    multipart.addBodyPart(attachementBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send(message);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • When I click send link my yahoo mail does come up BUT the link is coming up in the TO box

    I am trying to send a link to my friend and when I click send link my yahoo mail DOES pop up but the link is showing in the TO box
    instead of the body of the message...I have to cut and copy that and put
    in the message body then put the email address in the TO box

    [http://support.mozilla.com/en-US/kb/Changing+the+e-mail+program+used+by+Firefox]

  • Very difficult to send or reply yahoo mail.

    Very difficult to send or reply yahoo mail from iPhone and everything except mail works just fine,
    Sometimes when unable to send or reply, pop up on the screen "wrong username or password",
    Infact everything is correct, what happen with Yahoo ?
    Help please, it's been 3 days going on like this.

    Just to update....  On the iPhone, under yahoo account setup, there was a backup outgoing smtp at&t server listed, but not enabled.  I enabled the backup at&t outgoing server.  Now when the yahoo smtp server is unavailable the iPhone will default to the backup server.  Test of outgoing mail worked ok.

  • Can't send email through Apple mail

    I suddenly am not able to send email through Apple mail on my MacBookPro.  ipad and iphone still working.  I can also send email through att online.  My email is @att.net, and the message says "The server cannot be contacted on port 465".  (That is the proper port)

    Hi,
    Here are some suggestions,
    1. Try downloading another free email client to see if it works from there, just to eliminate other possibilities.
    2. Try removing the account in mail settings, and adding it again with the correct settings.
    Let me know what you find!
    Nolan

  • Having issues sending mail through mac mail on my imac .Have 4 accounts

    I am having issues sending emails through mac mail. Have 4 accounts and they are all having same issues
    Can receive mail ok
    have tired rebuilding the mail box but no improvment.
    i need to shut down system and restart to be able to send mail.

    I tried something similar by adding a new mail account doing the apple id etc but it worked in that it would look for mail but no mail would come even though mail still goes to my phone I was loath to delete my original account just in case the new one did not work as well. So I guess I am a little stuck now.. I hope you can help me to sort it out.
    Thanks

  • Authentication faild when sending email to yahoo mail

    I can not send email to yahoo mail address. The error message is:
    javax.mail.MessagingException: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    I tried different ways to do the authentication:
    1. Create a passwordAuthenticator (extends Authenticator) and set my yahoo userName and yahoo password there.
    then use this authenticator to get session:
    Session session = Session.getDefaultInstance(props, auth);
    I also tried both props.put("mail.smtp.auth",new Boolean(true));
    and props.put("mail.smtp.auth",new Boolean(false));
    2. using
    session.setPasswordAuthentication(new URLName("smtp.mail.yahoo.com"), new
    PasswordAuthentication(myYahooUserId, myYahooPasswoed);
    3. using Transport instance:
    Transport transport = session.getTransport("smtp");
    transport.connect(host, myYahooUserName, myYahooPasswoed);
    msg.saveChanges();
    transport.send(msg);
    transport.close();
    None of the above approaches are working.
    Can any one hlep?
    Thanks

    I am looking at the last line in step 1 in the code,
    and am wondering why the auth is set to false? I am
    new to this area, so just curious, not trying to
    provide an answer :-)I just tried with Rogers SMTP server, it is OK .. here is my code
    Properties props = System.getProperties();
                   //Authenticator auth = new
                   // -- Attaching to default Session, or we could start a new one --
                   props.setProperty("mail.transport.protocol", "smtp");
                   props.setProperty("mail.host", smtpServer);
                   props.setProperty("mail.user", acctName);
                   props.setProperty("mail.password", password);
                   props.setProperty("mail.smtp.auth","true");
                   Session mailSession = Session.getDefaultInstance(props, null);
                   Transport transport = mailSession.getTransport();
                   MimeMessage message = new MimeMessage(mailSession);
                   message.setContent(subject, "text/plain");
                   message.addRecipient(Message.RecipientType.TO,
                        new InternetAddress(to));
                   Address replyList[] = { new InternetAddress(from) };
                   message.setReplyTo(replyList);
                   message.setFrom(new InternetAddress(from));
                   //transport.connect();
                   transport.connect(smtpServer, acctName, password);
                   transport.sendMessage(message,
                        message.getRecipients(Message.RecipientType.TO));
                   transport.close();

  • Creation of transport rule to send all external mails through a particular server for a specific user..

    HI,
    In our Organisation We have a question, is there any possibility to create a transport rule for sending all external mails through a particular server by a specific user.
    in our organisation we have exchange 2007 one mailbox server and two hub transport servers...and we are using symantic gate way..

    Hi,
    Based on my knowledge, we can use the following transport rule to make that except with one user, other users cannot send outbound external emails:
    And I’m afraid that there is no Exchange feature to make one specific HUB server rout all external emails.
    Because if a Send connector is configured to send messages to an external domain, any Hub Transport server in the organization will route a message for that domain to a source server for that connector to be relayed to the destination domain.
    If you have any question, please feel free to let me know.
    Thanks,
    Angela Shi
    TechNet Community Support

Maybe you are looking for

  • IMac or MacBook Pro Speed questions.

    I currently have the PB 1.67 Ghz. For those that have a New Intel MB-Pro or a iMac Core Duo could you please tell me if its a night and day difference in speed when using Motion? I'm Not talking rendering.. I'm talking interface speed. My current com

  • Two Buttons on my iPhone 4 & Its Accessory Keyboard Have All Stopped Responding.  What to do?

    The "Calendar" and the "Reminder" buttons on my iPhone 4 purchased in 9/2012 have stopped responding.  The phone has worked well to date.  What to do? I also use an accessory keyboard, which is made by Apple but is not listed online in the product op

  • How many domain names can I transfer to Apple.

    I have a family (me) account. Family of four/one biz. The family each has their own domain. The biz has 4 domains. Can I transfer all domains including the four biz domains to the apple/me account. Yes/No. Is there a limit? Also about a year ago I tr

  • How to find a package for SAPLUP:700

    Hello everyone, I am creating new sandbox, and i have Windows server 2003 and sql server 2005. I am doing it by system copy (import export) While exporting it asks for SAPLUP:700. which SL controller but i am unable to find SL controller as per menti

  • Upgrading from Crystal Enterprise 10 to Business Objects XI R3

    Hi Guys, I am upgrading from Crystal Enterprise 10 to Business Objects XI R3.  The server which have Crystal Enterprise 10 is not on the network, please let me know to copy CMS database from CRE10 (Not on the network) to BOXIR3. Burhan Thanks