Having problem sending mail to yahoo using a yahoo id(SendMailException)

Hi, I read almost all the post's related to javamail,but none of them seems to help me, and hence the reason for this post,
i've written a simple application(with reference to the one implemented on sun's site) that sends a message to a yahoo id using a yahoo id,
meaning
[email protected](recepient) and [email protected](sender)
the code is given below:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.mail.Authenticator;
public class MailSender
     String host = "smtp.mail.yahoo.com";
     String from = "[email protected]";
     String to = "[email protected]";
     public void sendMessage()
          try
               Properties props = System.getProperties();
               props.put("mail.smtp.host", host);
               props.put("mail.smtp.auth","true");
               Authenticator auth = new MyAuthenticator();
               Session session = Session.getInstance(props,auth);
               session.setDebug(true);
               MimeMessage message = new MimeMessage(session);
               message.setFrom(new InternetAddress(from));
               message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
               message.setSubject("Hello JavaMail");
               message.setText("Welcome to JavaMail");
               message.saveChanges(); // implicit with send()
               Transport.send(message);
          catch(Exception e)
               System.out.println("Sorry could not complete your Request, you have an error "+ e);
               e.printStackTrace();
     public static void main(String args[])     
          MailSender ms= new MailSender();
          ms.sendMessage();
     private class MyAuthenticator extends Authenticator
     public PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("someoneelse","password");
It compiles but when i execute it i get a nested exception
nested exception is:
javax.mail.AuthenticationFailedException
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at MailSender.sendMessage(MailSender.java:32)
at MailSender.main(MailSender.java:45)
Does anyone know a solution to this problem?

Sure, you can put a local mail server on ur machine to test out sending and receiving in javamail. There r several mail server implementations out there, I personally prefer James (available at http://apache.org) It is pure java based mail server providing full POP3 and SMTP functionality.
Once u configure a local mail server, u can use emailids like xyz@localhost or acme@localhost

Similar Messages

  • TS3276 Anyone having problems sending mail from Os X10.7.2?

    Anyone having problems sending mail from Os X10.7.2?
    i have Mac book pro,  I mac Desk top and i pad:All can receive mail but not send. I have checked and re checked set up etc No luck
    Thx

    Hi Ernie,
    Sorry I don't understand the first question :{
    Connection Doctor says everything is connected. i can send mail from the server's own web site ,just not from the Apple Mail program.
    The problem did begin when I was travelling from one hotel to another.
    Any ideas?
    Susan

  • Having problem sending mail through iMAC to PC outlook express.

    i have iMAC MAC OS X 10.3.9 and using mail to send/receive messages.
    I m having problem sending messages to outlook Users as when i send any message to them with different font colors so they receive message but in all Black color,and while when i send the same message with different Font color to Mac users so they receive same message which i sent with different Font color.
    In both conditions my message in sent item shows all colors which i have done but outlook users do receive message but with all Black color. Plz give me an opinion to solve this problem.

    If you are accessing your Comcast POP account with Outlook Express on your Windows PC, create your .Mac account as an IMAP account with OE.
    Create a .Mac server stored mailbox for Comcast received messages and another for Comcast sent messages.
    Copy the messages from the Comast Inbox and Sent mailbox to the designated server stored .Mac mailboxes.
    After doing so, when launching the Mail.app on your Mac, these server stored mailboxes created with OE on your Windows PC and the transferred messages will be available.
    Create two "On My Mac" location mailboxes - one for the transferred Inbox messages and one for the transferred sent messages. Transfer the messages from the server stored mailboxes to these "On My Mac" location mailboxes. This process will store the messages locally on the hard drive and remove the messages from the server at the same time.

  • HT4061 why aim having problems sending mail?

    why am having problems seinding mail in my Iphone5?

    Hey Alma102!
    Here is an article that will help you troubleshoot this issue with your ability to send emails from your iOS device:
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • HT1430 Anyone having problems sending email with yahoo?

    Is anyone having problems with yahoo mail?  I can receive messages but haven't been able to send one for the last several hours.

    Yahoo has had a randomly persistent issue for weeks. I went through two separate times of being unable to access one of my accounts. It usually cleared up in 24 hours or so. (Suggesting it's their servers that are creating the issue)
    Have you tried to delete then readd the account?

  • Problem sending mail from Yahoo acct via iPhone

    Hello all,
    Everything on my iPhone works great. I discovered how to set up Yahoo and it receives mail just fine, but when I compose a message or reply nothing seems to happen, the message just disappears. The message does not show up in my "Sent Items". I also have a Gmail account and everything is fine there. Does anybody have any ideas? Thank you.

    I am having a similar problem with my email account. I set up the profile and receive emails fine on the iPhone but can't send emails. I get message "cannot send mail" check account settings for server. looks rights
    Anyone solve this problem???

  • Having problems sending mail

    2nd blackberry, had the same problem on the first one.
    when i try and type an e-mail, I would type the first letter of the name and the list of all names with that letter would drop down, and then I would enter the info,
    now for the 2nd time, on the 2nd blackberry, I lost that option, it wont let me send an e-mail either, if I type a name in, or an e-mail in, and try to send an e-mail it wond let me.
    I can only reply to e-mails,
    if anybody has any suggestions, otherwise I am going to get my 3rd blackberry this week.
    thanks
    josh

    This is not a hardware problem so getting another BlackBerry isn't going to fix it.
    What kind of BlackBerry?  What email service do you have set up?  is this a work or a personal device?  Work or personal email?  Did you plug the BB into the desktop manager on your pc?  We can help but we need as much information as you can provide.
    1. Please thank those who help you by clicking the "Like" button at the bottom of the post that helped you.
    2. If your issue has been solved, please resolve it by marking the post "Solution?" which solved it for you!

  • I have problems sending mail in Yahoo

    when I tried to send an email in yahoo, after I hit the send button, kept loading the page for five minutes and did not send.
    == URL of affected sites ==
    http://www.yahoo.com

    On the off chance anyone is watching the thread ...
    I seem to have resolved the issue of sending a photo to my wife through messages by turning off iMessage, then rebooting (not resetting) the phone.
    I still have the issue in Photos. If I select the share icon, then select message, it brings up a message authoring window with the photo in it, but never offers an opportunity to select a contact to send it to.

  • Having problems SENDING mail through hostway account (relay error msg)?

    Want to spare others the 2 week nightmare of configuring email so that "relay error" message would not prevent emails from being sent.
    Settings / Accounts/ mail/ then...
    1. enter pop/smtp account and pw
    2 SMPT settings: "authentication" - check "password"
                               SSL - "OFF' if port setting is 587
                                         "ON" if port setting is 465
    3. Enter both user name and password where it says "optional"
    Good luck!

    Try this, it will create a mailbox in messaging and work like your desktop, to refresh you need to hi-lite the mailbox then select options-sync email, use it on my N97 instaed of standard email
    http://forum.dailymobile.se/index.php?action=dlattach;topic=426.0;attach=43906
    Just download to pc drag and drop to phone and install !
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • Problems Sending Mail -- ISP or Mac Mail?

    Typically, I need to send nearly every message at least twice -- once initially and however many times after that from the outbox until it finally goes. At times, I'll have mail stuck in my outbox for hours, if not days and often have to use webmail to send messages in a pinch (thus losing all the benefits of Mail).
    I contacted my ISP and spoke to a technician who was very helpful and attentive. I sent him screengrabs of all of my settings and he confirmed they are set correctly. However, he dismissed my belief that this is related to the ISP and said that it is probably something to do with my Mac Mail client, or my home network configuration. He suggested I switch to Entourage or another mail client, which I don't want to do.
    Either way, I'm skeptical about his response because prior to using this ISP I never had the problem with Yahoo using more or less the same configuration. (Both require authentication, POP3, etc.) Yahoo always accepted outgoing messages on the first try.
    Has anyone else seen this problem and can they share advice on what they did to fix it, or is the ISP blowing smoke up my skirt?

    I am also having problems sending mail. This has occurred for the past 6 weeks or so. Typically, I receive the drop down message about my ISP server: "Cannot send message using the server smtp.telus.net.....". I click the "try again later" button, open the Outgoing Mail box on Mail, click on the unsent email and it usually makes it out. This has become an annoying 4-step mail process.
    I contacted my ISP and they did their little tests and said that it all of my settings are fine (I wasn't surprised; I haven't changed anything) and said that I should contact my Mail client, Apple.
    I encounter the same problem regardless of who or how I send the mail...if I send to an address on the same ISP server, to mac.com, to yahoo, to private website accounts, etc. I've tried sending through mac.com, through my website account, etc. Nothing changes.
    From the many posts about this problem, it seems to be widespread.
    And sometimes, just sometimes, Mail sends my mail just like it did in the "good old" days, on the first click or keyboard shortcut.
    Has anyone found a workable solution to this annoying problem?
    I miss my Comm/Shift/D

  • Problem sending Mail

    I am having problem sending mail in Outlook (not using express). I receive mail no problem at all and I don't want to change account to IMAP to send mail. So what are my options to make this work using Outllok?

    Who is your internet service provider used for connecting to the internet?
    Are you also accessing an email account and SMTP server provided by your ISP and if so, can you send messages with this account?
    Does GoDaddy provide/support an authenticated SMTP server?
    Which server port are you using for this SMTP server - 25, 587 or something else?

  • Problems sending mail

    Hi folks, I am having problems sending mail. I have tried both Entourage and mail, and get the same problem that I can´t connect to the outgoing smtp server. I haven´t changed any settings... This just suddenly started happening. I can send mail with the exact same settings on another computer on my network here, so the server is in working order.
    Any help would be hugely appreciated.

    This issue should be brought to the attention of your ISP or whomever maintains your email server.

  • 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.

  • TS3276 Anyone experiencing problems sending mail using TalkTalk - can receive but not send  - was ok up until pm 24/08/12 - have recently loaded Mountain Lion patch could this be the problem?

    Anyone experiencing problems sending mail using Apple Mail viaTalkTalk - can receive but not send  - was ok up until pm 24/08/12 - have recently loaded Mountain Lion patch could this be the problem?

    jag157 wrote:
    "I managed to solve the problem. Under smtp settings (mail preferences/accounts/edit smtp) I set the outgoing port to 25 (as recommended by Talktalk), no authentication (set to none) and unchecked SSL. I found that until I set the port to 25 and authentication to none I was unable to uncheck SSL. One I had done this I was able to send from my main email and other email adddresses set up under my account."
    Superb advice R&W!  My email sending block using TalkTalk started 2 months ago using Snow Leopard, continued when I upgraded to 10.8.2, and has been persistent on my wife's new iPad (IOS 6.1).  Implementing your wise words has fixed all that, and now enables me to call her on FaceTime — previously only she could call me.  Thank you so much; this will save hours of further fruitless searching and phoning.
    Please remember that your email is now insecure, if you wish to have a secure connection SSL must be on and port 25 should be avoided.

  • Is anyone else having trouble sending mail?  I have a MobileMe subscription - not sure whether that is the problem.  The Port assigned to my mail account on my iMac has a different number for the one recommended by Apple, but I hesitate to change it.

    Is anyone else having trouble sending mail on an iMac running 10.6.8.  I get a messsage that the server can't be accessed.  Apple help suggests using a different port from the one that was originally set.  I have a Mobile Me account.  Any suggestions?

    I had major issues with the iPhone 4s battery, however it’s resolved.
    The tech who set the phone up at the Apple store did so with little training.
    if you have a mobile me account. First go and move all your data to the cloud by going on your computer and logging in at me.com/move. The cloud has replaced mobile me, so there is no need for those two accounts
    Also make sure that for any of your email accounts you set them up to fetch, not push. My tech person set them all to have the email servers push data to the phone. The new iphone4s antenna is extremely strong so it will continually try to access stuff that is pushed–***** a lot of battery life doing this. It makes it worse if you have exchange 2010 accounts. Something about changes made to exchange really suck battery life from devices that access such accounts.
    turning of locator and the push notifications from facebook--they have a lot!

Maybe you are looking for