title: FROM address incorrect
body: <p>The FROM: address in my emails sent from java don't appear correctly. This is not running in an application server but from a <code>main()</code> call:</p>
  
  <pre><code>// Get system properties
  final Properties properties = System.getProperties();
  
  // Setup mail server
  properties.setProperty("mail.smtp.host", "localhost");
  
  // Get the default Session object.
  final Session session = Session.getDefaultInstance(properties);
  
  // Create a default MimeMessage object.
  final MimeMessage message = new MimeMessage(session);
  
  // Set From: header field of the header.
  message.setFrom(new InternetAddress("support@mydomain.com"));
  
  // Set To: header field of the header.
  message.setRecipients(javax.mail.Message.RecipientType.TO, "you@you.com");
  
  // Set Subject: header field
  message.setSubject("Your pants are on fire!");
  
  message.setSentDate(new Date());
  
  // Now set the actual message
  message.setText("Take me to the bridge. ow!");
  
  // Send message
  Transport.send(message);
  </code></pre>
  
  <p>Here's the raw received email. Two things to note: the linux username under which the java process runs is <strong>mungo</strong>. The linux servername/hostname is <strong>servername</strong>. The domain is <strong>santamaria.com</strong>. These have been changed from their original to protect the guilty.</p>
  
  <p>My question is: why isn't Return-Path <strong>support@mydomain.com</strong> and how can I make it so? Secondarily, how can I add a friendly name? e.g. <strong>Roger Earl &lt;support@mydomain.com&gt;</strong></p>
  
  <pre><code>Delivered-To: you@you.com
  Received: by 10.70.125.201 with SMTP id ms9csp51721pdb;
          Sat, 22 Nov 2014 07:38:22 -0800 (PST)
  X-Received: by 10.140.84.71 with SMTP id k65mr15089869qgd.76.1416670702208;
          Sat, 22 Nov 2014 07:38:22 -0800 (PST)
  Return-Path: &lt;mungo@servername.santamaria.com&gt;
  Received: from servername.santamaria.com (servername.santamaria.com. [201.74.27.72])
          by mx.google.com with ESMTPS id z90si10522625qgd.46.2014.11.22.07.38.21
          for &lt;you@you.com&gt;
          (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
          Sat, 22 Nov 2014 07:38:22 -0800 (PST)
  Received-SPF: none (google.com: mungo@servername.santamaria.com does not designate permitted sender hosts) client-ip=201.74.27.72;
  Authentication-Results: mx.google.com;
         spf=none (google.com: mungo@servername.santamaria.com does not designate permitted sender hosts) smtp.mail=mungo@servername.santamaria.com
  Received: from servername.santamaria.com (localhost [127.0.0.1])
      by servername.santamaria.com (8.14.4/8.14.4) with ESMTP id sAMFcLkq012340
      for &lt;you@you.com&gt;; Sat, 22 Nov 2014 15:38:21 GMT
  From: RogerEarl &lt;mungo@servername.santamaria.com&gt;
  Date: Sat, 22 Nov 2014 15:38:21 +0000 (UTC)
  To: you@you.com
  Message-ID: &lt;1542856295.1.1416670701712.JavaMail.mungo@servername.santamaria.com&gt;
  Subject: Your pants are on fire!
  MIME-Version: 1.0
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  Take me to the bridge. ow!
  </code></pre>
  
  <p><strong>UPDATE</strong>
  The working code looks like this:</p>
  
  <pre><code>properties.setProperty("mail.smtp.from", "support@mydomain.com");
  message.setFrom(new InternetAddress("support@mydomain.com", "My Friendly Support Name");
  </code></pre>