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

Similar Messages

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

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

  • 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

  • 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();

  • I can't send emails through Yahoo using Firefox. Already contacted Yahoo and they don't know why it's happening.

    I can't send emails through Yahoo using Firefox. Already contacted Yahoo and they don't know why it's happening.
    == This happened ==
    Every time Firefox opened
    == a month agao

    I also cannot send email through Yahoo using Firefox 3.6.8. I can receive emails and surf the web just fine. I have also contacted Yahoo and have gotten no where.

  • Cannot send email from yahoo mail client

    I cannot open or send or attach anything to my email in the yahoo mail.  I know there's nothing wrong with the email because it works on my laptop, just not on my computer.  Could there be a setting problem, or a cookie problem or something?
    I also cannot open Bonjour to see my printer settings.  Everything was working fine yesterday.

    outgoing mail server
    SMTP - Yahoo! SMTP Server
    primary server
    Yahoo! SMTP server - ON
    server port 465
    That's what I have for my yahoo account.

  • Can't send email on yahoo mail, keeps switching to windows mail and smtp errors ?

    When browsing using Firefox if I try and send URL or email it automatically tries to send it on Windows Mail rather then the Yahoo mail I normally use, then windows mail can't send any email out saying smtp error. Can send yahoo mail fine ?

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

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

  • I'm unable to send and receive email through Apple Mail 4.  I've checked my settings on Preferences, and my password to Gmail is up to date for syncing with IMAP, but it still won't connect.  Suggestions?

    I'm unable to send and receive email through Apple Mail 4.  I've checked my settings on Preferences, and my password to Gmail is up to date for syncing with IMAP, but it still won't connect.  Suggestions?

    I think it's trying to open it in a gMail eMail & is losing your gMail password that it needs log into gMail, but not 100% positive.
    Have you tried Right clicking or Control+click on the eMail link & choose Copy? Works on some, not others.

  • TS3276 I receive a pop up from ICal saying the server does not recognize me user name and password.  This started yesterday.  I have no problems with receiving or sending emails through Mail

    I receive a pop-up from ICal saying the server does not recognize my user name and password for my me.com email address.  This started yesterday and occurs about every 5 minutes or so.  There are no problems with receiving or sending email through Mail.  I did change me email password several days ago but have no problems sending/receiving since then.

    I fixed the problem.  I opened Preferences in ICal and entered my new password.  No more pop-ups

  • TS3899 When sending email from the Mail App or through other Apps, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design.

    When sending email from the Mail App or through other Apps on my iPad, my default From: address will change when I enter a To: address.  This sometimes leads me to send the email from the wrong outgoing email account.  It is frustrating and poor design, especially since I had already checked the From: address.
    iPad 4 running iOS 8.1.3

    3rd party email addresses have to be deleted on every synmced mac product, although I have 1and1.co.uk and my imac updatetes the mails in that account from mac mail.
    Yahoo etc is a 2 step deleting process but good to get your emails pushed when on the go.
    LJ
    http://www.facebook.com/The.Cowboy.Party

  • Can't send email through my aol mail on my iPad 2 after updating to iOS 7

    I had to update m iPad because I was no longer able to work a lot of my apps because they kept telling me that there was an update that I had to do in order to even work my apps!  I was very reluctant to do it in the first place fearing that I would loose a lot of my pics, videos and or more!  Anyway so the other day I sat down and finally did it.  After updating my iPad 2 to the new operating system of iOS 7 now I cannot send emails through my aol mail on my iPad.  I tried putzing with the settings for smtp and to no avail nothing,  I then decided well maybe downloading the aol app would help but still not good enough because it takes up so much room that I had to delete some apps just to get it.  I had since deleted the aol app and am still trying to figure out why I keep getting the message I am getting is incorrect] hen it gives me two options which are option 1) Settings and option 2) Cancel.  I am in need of assistance here because I can receive mail but cannot send it.  Oh and I am able to send mail through my other email addresses on my iPad mail including my me.com and iCloud.com as well as two others but am not able to send through aol.  I am loosing my patience with apple very quickly as one why did I have to update the system and why am I forced to update my apps which I feel is completely ridiculous in the first place.  Everything was fine until I had to do that and now I cannot keep my iPad on for more then an hour when the battery drains so quickly now because I guess it takes up so much unneeded space!  PLEASE HELP ME!
    <Email Edited by Host>

    Hello, PriestessJeanann. 
    Thank you for visiting Apple Support Communities.
    Here is an article I would recommend going through when experiencing issues with mail.  The usual fix would be to delete the email account in question and add this account via the preset AOL option.  I would also recommend checking with your email provider for security procedures such as two-step verification as this could cause this issue.
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    Cheers,
    Jason H.

  • HT2480 I need help syncing my computer outlook email (through Yahoo) with my Iphone. when I delete an email on my computer is it still in my inbox on my phone.  Any help is appreciated.

    I need help syncing my computer outlook email (through Yahoo) with my iphone.  When I delete an email on my computer it is still in my inbox on my phone. Please help.

    Your computer is probably set up to access your Yahoo mail using POP3. POP3 does not synchronize with the server. For full synchronization, you will need to use IMAP instead. See the Yahoo mail help pages for instructions on how to configure your mail client.

Maybe you are looking for

  • Problem with updating XI 3.0 (Kernel etc.)

    Hi, well i finally did all the patching to SP 19, everything worked fine. Except the Kernel patch. I have an error concerning CL_BSP_MODEL where i found note 869197 to update the Kernel (we have 43 - should be 48 for getting rid of the error) Therefo

  • I got a big problem that iPlanet 6.0 SP2

    Hi, I got a big problem that iPlanet 6.0 SP2 is in cycle of restart. The web server's error logs is the following: [16/Jul/2002:00:30:05] info ( 8545): successful server startup [16/Jul/2002:00:30:05] info ( 8545): iPlanet-WebServer-Enterprise/6.0SP2

  • The place command in Bridge14, not link to photoshop14?? anyone help me

    The place command in Bridge14, not link to photoshop14?? anyone help me

  • Smart card-account user

    Hi, I have a question here. What is the features that can make smart card stored users' account ID? When the user access Sunray, they will get a Windows environment and this session will carry-on as long as the users access their own system.

  • REportwriter:  create a library of Table "FAGLFLEXA"

    Hi, I tried to create a library of table FAGLFLEXA in report writer (GR21) but report writer says: "Table FAGLFLEXA is not installed in Report Writer. Message no. GR493. The Report Writer can only report on tables if the attributes of these tables th