Senden von E-Mails von der Yahoo-ID an andere E-Mail-IDs mithilfe der Javamail-API

Ich kann mit der Java-Mail-API keine E-Mails von meiner Yahoo-ID senden. Ich habe verschiedene Optionen von Google ausprobiert, aber es schlägt fehl. Bitte werfen Sie einen Blick auf den folgenden Code und lassen Sie mich wissen, wenn ich etwas vermisse. Aus meiner SichtYahoo bietet nicht den kostenlosen Service zum Versenden von E-Mails, aber ich bin mir nicht sicher. Bitte geben Sie Ihre Gedanken dazu.

import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;

public class MailExample {
    private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
    private static final int SMTP_HOST_PORT = 587;//465,587,25
    private static final String SMTP_AUTH_USER = "[email protected]";
    private static final String SMTP_AUTH_PWD  = "my password";

    public static void main(String[] args) throws Exception{
       new MailExample().test();
    }

    public void test() throws Exception{
        Properties props = new Properties();

        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.host", SMTP_HOST_NAME);
        props.put("mail.smtp.auth", "true");
        // props.put("mail.smtps.quitwait", "false");

        Session mailSession = Session.getDefaultInstance(props);
        mailSession.setDebug(true);
        Transport transport = mailSession.getTransport();

        MimeMessage message = new MimeMessage(mailSession);
        message.setSubject("Testing SMTP-SSL");
        message.setContent("This is a test", "text/plain");

        message.addRecipient(Message.RecipientType.TO,
             new InternetAddress("[email protected]"));

        transport.connect
          (SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);

        transport.sendMessage(message,
            message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }
}

Der obige Code funktioniert gut für Google Mail, aber für Yahoo gibt es Fehler wie:

DEBUG: setDebug: JavaMail version 1.4.1 DEBUG: getProvider() 
  returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,
  Sun Microsystems, Inc.,1.4.1] DEBUG SMTP: useEhlo true, 
  useAuth true 
DEBUG SMTP: trying to connect to host "smtp.mail.yahoo.com", port 587, 
  isSSL false Exception in thread "main" 
javax.mail.MessagingException: Could not connect to SMTP 
  host: smtp.mail.yahoo.com, port: 587;   nested exception is:  
java.net.ConnectException: Connection timed out: connect    
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)  
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)  
at javax.mail.Service.connect(Service.java:288)     
at com.sample.mailexample.MailExample.test(MailExample.java:313)    
at com.sample.mailexample.MailExample.main(MailExample.java:291) Caused by: 
   java.net.ConnectException: Connection timed out: connect     
at java.net.PlainSocketImpl.socketConnect(Native Method)    
at java.net.PlainSocketImpl.doConnect(Unknown Source)   
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)    
at java.net.PlainSocketImpl.connect(Unknown Source)     
at java.net.SocksSocketImpl.connect(Unknown Source)     
at java.net.Socket.connect(Unknown Source)  
at java.net.Socket.connect(Unknown Source)  
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)     
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)    
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)  
... 4 more

Wie kann ich das lösen?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage