Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

SMTP Email for Android (Send emails from Android)

Just write few lines of code.

final String username = "yourname@yourcompany.com";
final String password = "yourpassword";

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.example.com");
props.put("mail.smtp.port", "587");

Session session = Session.getInstance(props, new javax.mail.Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
    }
});

try {

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("to@yourdomain.com"));
    message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse("to@yourdomain.com"));
    message.setSubject("Testing Subject");
    message.setText("Dear Dude,"
            + "\n\n I came from Android SMTP!");

    Transport.send(message);

    System.out.println("Done");

} catch (MessagingException e) {
    throw new RuntimeException(e);
}

Configure your email server and enjoy.

About

Send SMTP emails directly from Android using Java - (AndroidEmail)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages