title: How to send an email using JavaMail via Google App Engine
body: <p>I am new in the APP Engine Google world but I have my project into there and to send emails I am using JavaMail API and it's working well, but I need to change the "From" field  to an non-existent account or different from my personal account (I am not sure if it's necessary register in APP Engine the account what I need to appear in the "From" field). The emails that I have sent use my account authenticated in the "From" field (which it is obvious, isn't it). So the question is if it is possible? I read many websites about this question also from this website but I still not working.
  Google APP engine has Gmail API in the API manager, but I am no sure if it's the same as using JavaMail API.</p>
  
  <p>Some of my code that sends emails but using the authentication from my account:</p>
  
  <pre><code>public void sendEmail(String[] recipients, String subject, String body, String username, String password) {
  
  Properties props = new Properties();
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.starttls.enable", "true"); //I tried disabling this but it not works
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.ssl.trust", "smtp.gmail.com");
  props.put("mail.smtp.port", "587"); //I tried with another port
  
  //I tried without authentication from my account like this:
  //Session.getDefaultInstance(props, null); 
  //It not works
  session = Session.getInstance(props, new Authenticator() {
       @Override
       protected PasswordAuthentication getPasswordAuthentication() {
       return new PasswordAuthentication(MailService.this.username, MailService.this.password);
      }
  });
  
  Message message = new MimeMessage(session);
  // Here is the key, sending email not from authenticated account
  message.setFrom(new InternetAddress("whateveraccount@example.com", "whateveraccount.engine@example.com")); 
  message.setReplyTo(InternetAddress.parse("whateveraccount@example.com",false));
  
  //Sending to multiple recipients
  Address[] to = new Address[recipients.length];
  for (int i=0; i&lt;recipients.length; i++) {
      to[i] = new InternetAddress(recipients[i]);
  }
  
  message.setRecipients(Message.RecipientType.TO, to);
  message.setSubject(subject);
  
  /**
   Multi part message email
   **/
  
  Multipart multipart = new MimeMultipart();
  
  //body
  MimeBodyPart htmlPart = new MimeBodyPart();
  htmlPart.setContent(body, "text/html");
  multipart.addBodyPart(htmlPart);
  
  // adds attachments
  String[] attachFiles = new String[2];
  attachFiles[0] = "..path to send attachment..";
  attachFiles[1] = "..path to send attachment..";
  
  if(attachFiles != null &amp;&amp; attachFiles.length &gt; 0){
      for (String filePath : attachFiles) {
          MimeBodyPart attachPart = new MimeBodyPart();
          try {
              attachPart.attachFile(filePath);
          } catch (IOException ex) {
              ex.printStackTrace();
          }
          multipart.addBodyPart(attachPart);
      }
  }
  
  message.setContent(multipart);
  Transport.send(message);
  }
  </code></pre>
  
  <p>Updated:
  More specifically I need the configurations into Google App Engine.</p>