1

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 hotmail:
smtp.live.com

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

how this code work for hotmail and yahoo?

Community
  • 1
  • 1
Kamran Omar
  • 1,815
  • 9
  • 31
  • 49

2 Answers2

4

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
Reno
  • 33,594
  • 11
  • 89
  • 102
  • get the following error : javax.mail.MessagingException: Could not connect to SMTP host: smtp.live.com, port: 587; – Kamran Omar Feb 23 '11 at 12:53
  • second error : com.sun.mail.smtp.SMTPSendFailedException: 553 From address not verified - see http://help.yahoo.com/l/us/yahoo/mail/original/manage/sendfrom-07.html – Kamran Omar Feb 23 '11 at 12:58
0

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");   
mH16
  • 2,356
  • 4
  • 25
  • 35