javax.mail not including Sender Name in emails

No matter what I try, I can't get the Sender Name to show up in the outgoing mails sent through the javax.mail Session class.

Please note that I'm using Rhino so there's a mixture of javascript and java here, but the code problem exists in pure java as well.

var _java = JavaImporter(javax.mail, javax.mail.internet, java.util);

        var props = new _java.Properties();
        props.put("", myHost);
        props.put("mail.smtp.port", "465");
        props.put("mail.smtp.user", myUserName);
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.socketFactory.port", 465);
        props.put("mail.smtp.socketFactory.fallback", "false");
        props.put("mail.smtp.ssl", "true");

        var session = _java.Session.getInstance(props);

        var message = _java.MimeMessage(session);
            new _java.InternetAddress("myEmailAddress", "My Full Name")
            [new _java.InternetAddress("", true)]
        message.setSentDate(new Date());
        var t = session.getTransport("smtp");
        t.connect(myUserName, myPassword);
        t.sendMessage(message, message.getAllRecipients());

The email that comes through has:

Sender: Personal Name <>

But the from is always:


Therefore, mail clients like Outlook and Gmail aren't plucking out the name.

I've tried adding

props.put("mail.smtp.from", "Full Name <>")

but this doesn't make any difference.

Anybody have any experience with this bug?



What a pain.

The bug was that I was using message.setSender instead of message.setFrom.

Changing that solved it.

Need Your Help

Java 8 - Default methods for equals and hashcode

equals java-8 hashcode behavior default-method

I have created default methods in an interface for implementing equals and hashcode in predictable manner. I use reflection to iterate all fields in a type (class) to extract the values and compare...

Highlighting a row in a JSF page is not working

java javascript jquery html jsf-2

I want to highlight a row in a JSF table. This is the code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.