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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With