5
votes

I am writing an app to send email programmatically without using Intent.

I was able to write the app using Java Mail API using SMTP with Gmail Authentication.

But this application supports to send email using only gmail Addresses. Using any Gmail address and password, I can send the email to any email address as well.

private Properties _setProperties() { 
    Properties props = new Properties(); 


props.put("mail.smtp.host", "smtp.gmail.com"); 

if(_debuggable) { 
  props.put("mail.debug", "true"); 
} 

if(_auth) { 
  props.put("mail.smtp.auth", "true"); 
} 

props.put("mail.smtp.port", _"465"); 
props.put("mail.smtp.socketFactory.port", _"465"); 
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
props.put("mail.smtp.socketFactory.fallback", "false"); 


    return props; 
  } 

But I want to use Any email address with Password Other than gmail and send the Email like Yahoo, etc. When I try with Yahoo, the Mail was not sent.

Please advice me to how to achieve this task.

Thank you in Advance.

1
Does any one knows how to send emails programmatically from any email address in Android? Please Help me to handle this app... - suneth rajamanthri
Please write the code u tried.. - Jhanvi
jHanvi: I have attached code which used to send the email. From this i was able to send From Gmail Addess only. But i want to send from yahoo, Hotmail etc. - suneth rajamanthri
Please check below link stackoverflow.com/questions/2020088/… It might help you - sachin pareek

1 Answers

6
votes

Port and host are variables, which vary for different providers. Example:

Gmail- Host: smtp.gmail.com , Port: 465

Hotmail- Host: smtp.live.com , Port: 587

Yahoo- Host: smtp.mail.yahoo.com , Port: 465

Change these values according to the provider you are using and it will be done.