Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android send email from any Email Address programmatically

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.

like image 655
suneth rajamanthri Avatar asked Dec 12 '13 05:12

suneth rajamanthri


1 Answers

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.

like image 116
Jhanvi Avatar answered Sep 22 '22 23:09

Jhanvi