cancel
Showing results for 
Search instead for 
Did you mean: 

'From' field at sending email

palba
Champ in-the-making
Champ in-the-making
Hi all.

I have a little problem, and i've been unable to find a solition trougth the documentation, so here it is…

As a part of a workflow, I have to send an email to the user. I do it with the following javascript code:

var mail = actions.create("mail");
mail.parameters.to = "test@test.com";
mail.parameters.subject = "You have a new task";
mail.parameters.from = "server@server.com";
mail.parameters.text = "You have a new task.\n\nhttp://…";
mail.execute(bpm_package);

That works, the mail is sent, and the user recives it. But the mail cames from the email direction of the user who advance the workflow, instead of coming from the address specified ( "server@server.com").

What am I doing wrong?

Thxs in advance…
5 REPLIES 5

sethatrothbury
Champ in-the-making
Champ in-the-making
Hey Palba,

We ran into this problem a while back and brought it up in a ticket. After looking for ourselves, we realized what the problem was:
We looked into the Java behind the email action and found the faulty code in org.alfresco.repo.action.executor.MailActionExecutor in the Alfresco 3.1.1 SDK.

  // set the from address
  NodeRef person = personService.getPerson(authService.getCurrentUserName());
  String fromActualUser = (String)nodeService.getProperty(person, ContentModel.PROP_EMAIL);
  if( fromActualUser != null && fromActualUser.length() != 0)
   {
     message.setFrom(fromActualUser);
   }
   else
   {
     String from = (String)ruleAction.getParameterValue(PARAM_FROM);
      if (from == null || from.length() == 0)
        {
          message.setFrom(fromAddress);
        }
       else
       {
          message.setFrom(from);
       }
    }

So you can see the first thing it tries to do is retrieve the authenticated user. Then it tries to retrieve that user’s email property. If one is set it uses that, ignoring any action parameters. Only if the user doesn’t have an email set does it use the action parameter.

You could extend your own version of the action handler, thats what we ended up doing.

-Seth

palba
Champ in-the-making
Champ in-the-making
Hi, Seth.

You're right. I checked the source of MailActionExecutor, and the bug is still present at Alfresco 3.2.

I'll try to figure out a workaround. Thank you for the hint! Smiley Happy

uskiki85
Champ in-the-making
Champ in-the-making
The bug is still present at Alfresco 3.4.d

Any workaround ?

mikeh
Star Contributor
Star Contributor
Did anyone raise this issue in JIRA? If not, it's highly unlikely to have been fixed.

Mike

uskiki85
Champ in-the-making
Champ in-the-making
I have found a fix  for 3.1

MailActionExecuter.java : http://issues.alfresco.com/jira/browse/ALF-459

I make a try to adapt to 3.4.d