How do I change the setFrom() method to whatever I want? I can send e-mails through my gmail accoutn and change the setFrom text, but it shows my username
for t
(Assuming I understand your goal and it's not to send spam) The Apache Commons library we use does it by calling setPersonal
on the InternetAddress
. http://docs.oracle.com/javaee/7/api/javax/mail/internet/InternetAddress.html#setPersonal-java.lang.String-java.lang.String-
Message message = new MimeMessage(session);
InternetAddress me = new InternetAddress("from-email@gmail.com");
me.setPersonal("My name");
message.setFrom(me);