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.
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:
… and tried editting it, and it’s save actions, but that didn’t allow me to change any mail settings…
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:
… so I pulled them out into a text editor – and found references to the live email server.
So it appears that when a Save Action is used, it copies it’s 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 it’s 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 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 happen 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 (Email Confusion – Configuring SMTP options for your Sitecore Modules) to this problem:
Web Form For Marketers has it’s own send email action which by default overrides your MailServer with it’s own “example.host” – not to 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 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, and to make sure that those default values are removed for every system I build in the future. More fun.
Still, I hope that’s useful.