开发者

how to send email from hotmail and yahoo?

开发者 https://www.devze.com 2023-02-12 16:23 出处:网络
I am following answer no 8 from the following post: SMTP Sample Code it is working fine for the gmail.

I am following answer no 8 from the following post:

SMTP Sample Code

it is working fine for the gmail. but not working for hotmail and yahoo. i define following smtp server

SMTP Server for h开发者_如何学编程otmail:
smtp.live.com

SMTP Server for yahoo:
plus.smtp.mail.yahoo.com

how this code work for hotmail and yahoo?


Read about :

  • Yahoo smtp settings and
  • Hotmail smtp settings

Note the port numbers and other details

for example, hotmail

private String mailhost = "smtp.live.com";  

and

props.put("mail.smtp.port", "587");   
props.put("mail.smtp.socketFactory.port", "587");   // because of SSL


I am able to send mail using this code: Make sure you perfectly checked your smtp port and smtp host.

enter code here



 private String mailhost = "smtp.mail.yahoo.com";  

 // private String mailhost = "plus.smtp.mail.yahoo.com"; 
    Properties props = new Properties();   
    props.setProperty("mail.transport.protocol", "smtp");   
    props.setProperty("mail.host", mailhost);   
    props.put("mail.smtp.auth", "true");   
    props.put("mail.smtp.port", "25");   
0

精彩评论

暂无评论...
验证码 换一张
取 消