cancel
Showing results for 
Search instead for 
Did you mean: 

mailfrom address when using runas

singleton
Champ in-the-making
Champ in-the-making
Hi,

I've a public webscript, giving the ppl the possibility to retrieve a new password. Since this webscript is called from share without logging in and sets a new password it has a runas admin configuration on the alfresco webscript.

<?xml version="1.0" encoding="UTF-8"?>
<webscript>
   <shortname>Password reset</shortname>
   <description>Reset mechanism for login passwords</description>
   <url>/itanks/resetpassword?email={email}</url>
   <authentication runas="admin">none</authentication>
   <transaction>required</transaction>
</webscript>

Some code

Action act = getActionService().createAction(MailActionExecuter.NAME);
Map<String,Serializable> mailParameters = new HashMap<String,Serializable>();
mailParameters.put(MailActionExecuter.PARAM_TO, emailAddress);
mailParameters.put(MailActionExecuter.PARAM_FROM, emailFrom);
mailParameters.put(MailActionExecuter.PARAM_SUBJECT, emailSubject);
mailParameters.put("text", text);
act.addParameterValues(mailParameters);
act.setExecuteAsynchronously(true);
getActionService().executeAction(act, null);

When setting the properties:
mailParameters.put(MailActionExecuter.PARAM_FROM, emailFrom);
this setting is overruled by alfresco and instead the mail address of the admin user is used. Mail is delivered but with wrong from-address

Is there a way to use a custom from address?
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

this issue is eerily familiar. There is no way to overrule the Alfresco overruling, that is to use a different from address than the email from the currently logged in user (which in your case is admin). All in all, the Alfresco Email Action has proven to be too restricted / unflexible for our purposes, that we implemented a special Action (at least for the jBPM workflow domain) to handle all our emailing needs.

The only thing you may want to try, is to run the actual emailing code in a nested runAs context within your web script. When you know the user you may execute this in his context, otherwise you could use system, which should not have an email and thus Alfresco shouldn't overrule your mailFrom parameter.

Regards
Axel Faust

singleton
Champ in-the-making
Champ in-the-making
Hi,

Its working now with running the alf-webscript as the user "system". The email-from is used from the prop file.

Many thanks for your answer!