2 Replies Latest reply on Jul 3, 2014 10:39 AM by negora

    Mail service: How to configure the name of the sender?

    negora

      Hello:

       

      I've configured my mail service. I've set up the address of the sender using the attribute "from" of the element <mail-session>, in the configuration file $WILDFLY/standalone/configuration/standalone.xml. I've done this:

       

      <mail-session name="myMail" jndi-name="java:/myMail" from="me@mydomain.com">

       

      But I would like the sender to look like "Me <me@mydomain.com>". I've tried this:

       

      <mail-session name="myMail" jndi-name="java:/myMail" from="Me &lt;me@mydomain.com&gt;">

       

      The e-mails are sent correctly, but the header "From" still looks like "me@mydomain.com" instead of "Me <me@mydomain.com>".

       

      Is there a way to set a name for the sender, together with its address?

       

      Thank you.

        • 1. Re: Mail service: How to configure the name of the sender?
          ctomc

          Why don't you set sender as part of MailMessage when you are sending the mail?

          • 2. Re: Mail service: How to configure the name of the sender?
            negora

            Hello Tomaz:

             

            The reason why I'm trying to set it in the server's configuration file is the same that made me set the rest of the parameters there too: I want to move the configuration to the container level so that my application can be deployed elsewhere without the need of altering its content by hand.

             

            Some people may consider the sender address dynamic data that should be set in the application. But, in my opinion, in most  cases it's static data. So it can be considered part of the configuration too. In fact, Wildfly lets you configure the sender address at the container level. So, Why not to allow to configure the sender name or alias too?

             

            With regard to the use of MimeMessage to set the sender name, I've tried to use the method setSender (). However, it makes you specify an address. Which I don't want, because it overrides the address set in the configuration. Or am I wrong?

             

            Thank you!