2017-12-19 16 views
1

私は正常にメールを送信しますが、エラーはありませんが、私は受信箱にメールを受信しませんでした。 なぜこれが起こっていますか?メールが届かない

public static void main(String [] args){ 

    String to = "[email protected]"; 
    String from = "[email protected]"; 
    String host = "localhost"; 

//Get the session object 
    Properties properties = System.getProperties(); 
    properties.setProperty("mail.smtp.host", host); 
    Session session = Session.getDefaultInstance(properties); 

//compose the message 
    try{ 
    MimeMessage message = new MimeMessage(session); 
    message.setFrom(new InternetAddress(from)); 
    message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); 
    message.setSubject("Ping"); 
    message.setText("Hello, this is example of sending email "); 

    // Send message 
    Transport.send(message); 
    System.out.println("message sent successfully...."); 

    }catch (MessagingException mex) {mex.printStackTrace();} 
} 
+2

Yahooはおそらくこのようなメールをスパムとみなしているので、迷惑メールフォルダを確認してください。その理由:件名が疑わしい、あなたのGmailアカウントから送信していない可能性が最も高い(あなたのものと仮定して)コンテンツが短すぎます。 – Thomas

+0

あなたのローカルにSMTPサーバーが稼働していますか? – uday

+0

@Thomasありがとうございます。それはSPAMに保存されていました。 – Kuya

答えて

0

問題の原因を突き止めました。手紙は迷惑メールのセクションに行きました。私のE-mail fromフィールドには[email protected]から送信されたと書かれていますが、Gmail SMTPと同じアドレスを使ってこのE-mailを送信していません。それは私が電子メールを送信するために偽のアイデンティティーを使用しているようなものです。だから、私の受信メールサーバーはpartnersolutions.com.phだと思うのはスパムメールだと思います。

関連する問題