-1

When trying to send a mail using a 'friendly name' I get the error: 'We experienced a technical difficulty while processing your request. Your data may not have been correctly saved'

We want to show 'Friendly name' instead of no-reply@someextremlynicewebsite.com

What we did is in the send email editor enter this in the 'From' field:

"Friendly Name" no-reply@somesite.com;

Does anyone know the correct form for this principle?

EDIT: After investigating the sources from the sitecore libraries I found out there are differences between WFFM for sitecore 9.0 and WFFM for sitecore 9.0.1. I don't know if I can paste code from sitecore itself here but it seems that sitecore already started phasing out WFFM by using sitecore.forms as the base for sitecore forms.

In the processmessage class, getmail method this regex is being used, blocking all other formats:

^\w+([-+.']\w+)@\w+([-.]\w+)\.\w+([-.]\w+)*$

This code is not available in WFFM for sitecore 9.0

What is the best approach to fix this?

1

The following format might work:

"Friendly Name" <no-reply@somesite.com>

I've not tested this but as I understand it the MailAddress method in MailMessage should support this and I believe thats what WFFM is using here under the hood.

Update

If the above doens't work perhaps try patching in a pipeline to re-work the from address:

namespace MyProject.Wffm
{
    public class FormatFriendlyFromAddress
    {        
        public void Process(ProcessMessageArgs args)
        {
            args.From = $"{args.From} <no-reply@somesite.com>"; //make any changes to the address required here
        }
    }
}

Patch this in like so:

<pipelines>
  <processMessage>
    <processor type="MyProject.Wffm.FormatFriendlyFromAddress, MyProject.Wffm" method="Process" patch:before="processor[@method='SendEmail']"/>
  </processMessage>
</pipelines>
  • This does not work. Sitecore thinks it is a start tag and appends </no-reply@somesite.com> – Wilko van der Veen Sep 3 '18 at 11:20
  • Ok I've updated my answer to include a pipeline. again this is untested but if it doesn't' work perhaps try attaching the debugger and experimenting locally with setting the from address (maybe try encoded < > for example). – Adam Seabridge Sep 3 '18 at 11:46
  • This won't work since the getmail method from the processmessage class in Sitecore.Forms.Core.Pipelines uses a regex which blocks all other mail formats – Wilko van der Veen Sep 14 '18 at 6:48
0

You should take the working ProcessMessage class without REGEX from WFFM for Sitecore 9.0 and patch it instead of similar class in WFFM for Sitecore 9.0.1.

Replace two occurencies of "{Appropriate_method_name_goes_here}" in below config patch:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <processMessage>
        <processor type="YouCustomNamespace.YourCustomClass, YourCustomAssembly" method="{Appropriate_method_name_goes_here}" patch:instead="processor[@type='Sitecore.Forms.Core.Pipelines.ProcessMessage, Sitecore.Forms.Core' and @method='{Appropriate_method_name_goes_here}']" />
      </processMessage>
    </pipelines>
  </sitecore>
</configuration>

Could be that this has been added to avoid identifying sender as spammer or something similar on email providers like SendGrid or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.