2

I am using Sitecore 10.3, try to use the send mail action in Sitecore forms, I have modified the SMTP Settings in Sitecore.EDS.Providers.CustomSMTP.Sync.config as the below

enter image description here

and in web config

<add key="eds:define" value="CustomSMTP" />
<add key="exmEnabled:define" value="yes" />

and I tested the connection and it is working

enter image description here

but when I submitted the form the mail not sent and I see error in logs "ERROR [Experience Forms]: The SMTP host was not specified."

but I can not figure out what is wrong or missing, any ideas??

3 Answers 3

1

There is two Solutions for that

The First One is : option "Service email campaign" need to be checked on the "EMAIL EXPERIENCE MANAGER" - "Campaign creation" - "Delivery"Tab

enter image description here

The second Option is : to set consent Field on your "send Email" action

0

Send mail action is not using EXM settings.

It's using the following settings from <sitecore><settings> section of your configuration:

<setting name="MailServer" value="" />
<setting name="MailServerUserName" value="" />
<setting name="MailServerPassword" value="" />
<setting name="MailServerPort" value="" />

Make sure that you create a patch file which sets correct values here.

Patch file like this one should do the trick:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" >
  <sitecore>

      <settings>
          <setting name="MailServer">
              <patch:attribute name="value" value="..." />
          </setting>
          <setting name="MailServerPort">
              <patch:attribute name="value" value="..." />
          </setting>
          <setting name="MailServerPassword">
              <patch:attribute name="value" value="......" />
          </setting>
          <setting name="MailServerUserName">
              <patch:attribute name="value" value="..." />
          </setting>
      </settings>
  </sitecore>
0

Can you verify also these settings :

        <setting name=“MailServer” value=“localhost” />
        <!--  MAIL SERVER USER
                If the SMTP server requires login, enter the user name in this setting
          -->
        <setting name=“MailServerUserName” value=“” />
        <!--  MAIL SERVER PASSWORD
                If the SMTP server requires login, enter the password in this setting
          -->
        <setting name=“MailServerPassword” value=“” />
        <!--  MAIL SERVER PORT
                If the SMTP server requires a custom port number, enter the value in this setting.
                The default value is: 25
          -->
        <setting name=“MailServerPort” value=“8025” />
        <!--  MAIL SERVER SSL
                If the SMTP server requires SSL, set the value to true.
                The default value is: false
        -->

If you are using default SendEmail action from Sitecore forms, it use MainUtil.SendMail() method which use above settings :

 protected override bool Execute(SendEmailData data, FormSubmitContext formSubmitContext)
    {
      Assert.ArgumentNotNull((object) formSubmitContext, nameof (formSubmitContext));
      using (MailMessage mailMessage = new MailMessage())
      {
        try
        {
          SendEmail.SetMessageAttributes(mailMessage, data, formSubmitContext);
          this.MailSender.SendMail(mailMessage);
          return true;
        }
        catch (Exception ex)
        {
          this.Logger.LogError(ex.Message, ex, (object) this);
          return false;
        }
      }
    }

The MainUtil create SMTPClient using below code:

 private static SmtpClient CreateSmtpClient()
    {
      string mailServer = Settings.MailServer;
      SmtpClient smtpClient;
      if (string.IsNullOrEmpty(mailServer))
      {
        smtpClient = new SmtpClient();
      }
      else
      {
        int mailServerPort = Settings.MailServerPort;
        smtpClient = mailServerPort <= 0 ? new SmtpClient(mailServer) : new SmtpClient(mailServer, mailServerPort);
      }
      string mailServerUserName = Settings.MailServerUserName;
      smtpClient.EnableSsl = Settings.MailServerUseSsl;
      if (mailServerUserName.Length > 0)
      {
        string mailServerPassword = Settings.MailServerPassword;
        NetworkCredential networkCredential = new NetworkCredential(mailServerUserName, mailServerPassword);
        smtpClient.Credentials = (ICredentialsByHost) networkCredential;
      }
      return smtpClient;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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