Sending Email in Android using JavaMail API without using the default/built-in app

To send an email in Android using the JavaMail API without using the default/built-in app, you can use the following steps:

  1. Download the JavaMail API from the following link: https://javaee.github.io/javamail/
  2. Extract the downloaded file and add the javax.mail.jar file to your project's classpath.
  3. Create a new Java class to send the email and import the necessary classes from the JavaMail API:
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
  1. Use the following code to create a session and send the email:
// Set the email properties
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");

// Create a session with the email properties
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("[email protected]", "your_password");
    }
});

try {
    // Create the email message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]"));
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]"));
    message.setSubject("Email Subject");
    message.setText("Email body");

    //