commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard DiCroce (JIRA)" <>
Subject [jira] [Commented] (EMAIL-149) EmailConstants.MAIL_SMTP_FROM value is incorrect
Date Wed, 04 Mar 2015 23:22:39 GMT


Richard DiCroce commented on EMAIL-149:

It's been a while since I filed this so I might not have all the details straight anymore.
I don't have any debug output but the problem isn't hard to understand.

I configure a mail Session in WildFly, including the "from" attribute in WildFly's configuration.
WildFly creates the mail Session and binds it in JNDI. When creating the Session, WildFly
notices the from attribute and sets the value of "mail.from" in the Session, which is the
correct attribute to use according to the JavaMail Javadoc. I obtain the Session from JNDI
and provide it to the Email object. The idea here is that all of the necessary configuration
should have occurred when WildFly created the Session, so I should not need to call Email#setFrom().

But when I try to send the Email, I get an exception saying "From address required". This
occurs because of the checks in Email#buildMimeMessage() at lines 1315 to 1325. It first checks
if the fromAddress field in the Email itself is set. It isn't because I shouldn't need to
set it, as WildFly has already set the property in the session. Because fromAddress is null,
the code then checks whether the "mail.smtp.from" property is set in the session. It isn't
set because that is a non-standard property. And so an exception is thrown and the message
is not sent.

It looks to me like "mail.from" and "mail.smtp.from" are trying to do the same thing, hence
why I said the value of the MAIL_SMTP_FROM constant is incorrect. If they're not doing the
same thing, then the code should at least be adjusted to check "mail.from" in addition to
"mail.smtp.from" before throwing an exception.

> EmailConstants.MAIL_SMTP_FROM value is incorrect
> ------------------------------------------------
>                 Key: EMAIL-149
>                 URL:
>             Project: Commons Email
>          Issue Type: Bug
>    Affects Versions: 1.3.3
>            Reporter: Richard DiCroce
> Per the JavaMail Javadoc (, the standard property
for the from address is "mail.from", not "mail.smtp.from".
> This incorrect value causes sending emails to fail if using a Session provided by an
EE container that properly sets the from address. Observed on WildFly 8.2.0.Final.
> Workaround: add the "mail.smtp.from" value to the session properties. You don't need
to set the actual value, the fact that it's there is enough:
> session.getProperties().setProperty(EmailConstants.MAIL_SMTP_FROM, "");

This message was sent by Atlassian JIRA

View raw message