Twitter LinkedIn

CODE SITECORES SEND EMAIL MESSAGE SAVE ACTION RETAINS MAIL SERVER SETTINGS

  • By Andy Burns
Andy Burns
Today I faced an issue with Web Forms for Marketers (WFFM). We had taken a copy of a customer's system and were trying to test some changes we'd made to it. This involved making sure that the system sent email correctly, and we wanted it to send them to a mail-trap, rather than sending them to actual users. However, when I tried to change the mail server settings, the forms of the system seemed to continue to try to use the customer's live SMTP server. This was surprising.

I've noted before that Sitecore has a set of mail settings in Web.Config. As well as that we've got mail server settings in the definitions of the save actions in web forms for marketers. It's annoying to have to change both the web config and the save actions in Sitecore.

The Save Action

This is fine; I had reconfigured those.

Next, I wondered if the form itself would allow me to configure mail settings, so I went to the form:

Form

... and tried editing it, and its save actions, but that didn't allow me to change any mail settings

Editing the form
However, one of my colleagues suggested that I tried looking at the raw values for the form. There wasn't a lot of space to see them:

Raw Values
... so I pulled them out into a text editor - and found references to the live email server. 

Raw Values extracted
Email Confusion - Configuring SMTP options for your Sitecore (Modules)

So it appears that when a Save Action is used, it copies its details from the original one that's usually under /Sitecore/system/modules/Web Forms for Marketers/Settings/Actions/. It doesn't refer back to the original but takes a copy of its settings. There doesn't seem to then be a built-in way of changing those settings, which is, well, decidedly not very good. I was not impressed.

I could go through all the forms changing their settings via the raw values, but this would doubtless lead to problems sometime in the future when the customer changes their mail server. It also makes the promotion of content from test to live significantly more fiddly.

Talking to another of my colleagues, he suggested removing the mail settings from the save action - both the original and the 'copies'. He believed that if the save action lacks any mail server settings, then it uses the default ones defined in web.config. Obviously, this is what we probably want to have 95% of the time - that way we'd only have to configure the mail settings in one place. Configuring save actions to use other mail servers should be the exception, not the norm.

I also found a reference here (http://intothecore.cassidy.dk/2012/05/email-confusion-configuring-smtp.html) to this problem:

"Web Form For Marketers has its own send email action which by default overrides your MailServer with its own "example.host" – not too keen on their choice of default values here, but just remove it and it will default to your web.config settings"

Hmm, quite. So I decided to give it a go. I deleted the mail server settings highlighted in the text above, put that into the raw values, published, and retested my form. It worked nicely - now my email was going to the mail-trap.

Now I've just got the other forms to go through and do this for. Still, I hope that's useful.

Andy Burns
 
3chillies Reading (HQ) 4th Floor, The Blade, Abbey Square Reading Berkshire RG1 3BE 0118 931 4196 Find us
This website is hosted Green - checked by thegreenwebfoundation.org

Our Partners

  • microsoft partner logo
  • sitecore logo
  • umbraco logo
  • Optmizely logo
  • uMarketingSuite logo
  • Cookiebot
scroll back to the top of the current web page