Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29770

There is no email received

$
0
0

I successfully send the email, there is no error but I did not received any email in my inbox. why is this happening?

public static void main(String [] args){ 

  String to = "abc@yahoo.com";
  String from = "def@gmail.com";
  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();}  
}

Viewing all articles
Browse latest Browse all 29770

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>