0

Craft 3.3.0.1 Express Forms 1.0.4

I have an Express Forms set up. It submits and saves entries to the DB which can be viewed in the CP, however email notifications are not sent.

Sending a test email via settings > email works as expected as does a different Express Forms form, but this one does not and I am flummoxed.

when I check the Express forms log I see this: enter image description here

Here is a simplified template of my form where you can see the notification email address are set to a field in the page entry or if that is empty default email addresses are used.

{# 
// set send email address from careers entry 
#}
{% set sendEmailAddress %}
  {# loop through emails from job entry page and set the form to send to those emails #}
  {% for email in entry.applicationEmails %}
    "{{ email.emailAddress }}"{% if not loop.last %},{% endif %}
  {% else %}
  {# if empty send to this address #}
    "[email protected]", "[email protected]"
  {% endfor %}
{% endset %}

{# this testing div outputs emails as expected #}
<div class="testing">
  {{ sendEmailAddress }}
</div><!-- /.testing -->


{% set form = craft.expressforms.form("jobapplication") %}


{# General Error Handling #}
{% if not form.valid %}
    <div class="alert alert-danger" role="alert">
        {{ "Error! Please review the form and try submitting again."|t }}
        {% if form.errors|length %}
            <ul>
                {% for error in form.errors %}
                    <li>{{ error|t }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    </div>
{% endif %}


{{ form.openTag({
   return: '?success=1',
   dynamicNotifications: {
      to: [sendEmailAddress],
      template: "job-application.twig",
   }
}) }}

  {# 
    Various Fields here
  #}

  <button type="submit" data-application-submit class="btn btn-default" disabled>{{ "contact_submit"|t }}</button>

{{ form.closeTag }}

I've tried various approaches to using dynamic emails notifications but nothing seems to work.

My email notification template looks like this where {eMail} is the email field name in the form.

---
name: 'Job Application Email Notification Template'
description: 'submits job applications to reciever'
fromName: 'Strongco'
fromEmail: '$SYSTEM_EMAIL'
replyTo: '{eMail}'
cc: null
bcc: null
subject: 'Job Application: {positionAppliedFor}'
includeAttachments: true
---
<p>The following submission came in on {{ dateCreated|date('l, F j, Y \\a\\t g:ia') }}.</p>

<ul>
    {% for field in form.fields %}
        <li><strong>{{ field.label }}:</strong> {{ field.valueAsString }}</li>
    {% endfor %}
</ul>

Please advise.

2
  • I'm guessing the system email address is coming from an environment variable? If so, are you using dotenv?
    – Brad Bell
    Sep 7, 2019 at 0:03
  • @BradBell Yes and yes.
    – CreateSean
    Sep 9, 2019 at 12:48

1 Answer 1

0

I'm guessing if you update to the latest 3.x release of phpdotenv, the issue will resolve itself.

3.x added better support for environment variables running in multi-threaded environments. You can read some background info here: https://github.com/craftcms/cms/issues/3631

Note that you'll likely need to update how phpdotenv is loaded in your public index.php file. You can read the upgrade guide here: https://github.com/vlucas/phpdotenv/blob/master/UPGRADING.md

1
  • I moved my email details out of dotenv and saved them directly in the CP and the issue persists.
    – CreateSean
    Sep 12, 2019 at 14:16

Your Answer

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

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