1

I'm developing my first website on Craft 3 and I'm essentially a front-end designer so my PHP/MySQL/AJAX knowledge is extremely limited.

I installed the Contact Form plugin as explained here https://github.com/craftcms/contact-form and used the code example on the page (minus the redirectInput).

        {% macro errorList(errors) %}
        {% if errors %}
            <ul class="errors">
                {% for error in errors %}
                    <li>{{ error }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

    <form method="post" action="" accept-charset="UTF-8">
        {{ csrfInput() }}
        <input type="hidden" name="action" value="contact-form/send">
        {{ redirectInput('contact/thanks') }}

        <h3><label for="from-name">Your Name</label></h3>
        <input id="from-name" type="text" name="fromName" value="{{ message.fromName ?? '' }}">
        {{ message is defined and message ? errorList(message.getErrors('fromName')) }}

        <h3><label for="from-email">Your Email</label></h3>
        <input id="from-email" type="email" name="fromEmail" value="{{ message.fromEmail ?? '' }}">
        {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}

        <h3><label for="subject">Subject</label></h3>
        <input id="subject" type="text" name="subject" value="{{ message.subject ?? '' }}">
        {{ message is defined and message ? errorList(message.getErrors('subject')) }}

        <h3><label for="message">Message</label></h3>
        <textarea rows="10" cols="40" id="message" name="message">{{ message.message ?? '' }}</textarea>
        {{ message is defined and message ? errorList(message.getErrors('message')) }}

        <input type="submit" value="Send">
    </form>

But when I submit my form, the page reloads then zwoooosh, nothing happens! I can't tell if I'm not receiving the email or if it's not even being sent. I checked pretty much everywhere for similar issues but can't tell what's happening or not happening.

I didn't install any mail server on Ubuntu, I don't even know if that is necessary. I checked my Spam folder... I'm a bit lost at this point!

Any help would... help!

1

Welcome to Craft!

You mention you haven't configured any kind of mail server—this is almost certainly the issue.

There are a few mailer adapters for Craft, the availability of which will depend on whether you're using Craft 2 or Craft 3.

That said, the easiest route will probably be to use the built-in SMTP method, configured in the Settings -> Email screen of the Admin.

I'd recommend checking out Mailgun or Sendgrid as third-party services that handle mail delivery—this way, you're not responsible for maintaining your own mail server. Both offer generous free tiers that should cover most use cases.

Each should provide you with some SMTP credentials you can drop into Craft's settings.

Be aware: some ISPs will block SMTP traffic over the standard port. If you still have trouble sending mail, look at the docs for your chosen provider and see if they support sending over an alternate port.

Good luck!

| improve this answer | |
  • Probably worth mentioning as well: craftcms.com/support/troubleshooting-email-errors – Brad Bell Jun 8 '18 at 22:00
  • Hadn't seen this before! Thanks, @BradBell! – August Miller Jun 8 '18 at 22:15
  • Hey @AugustMiller thanks a lot for your suggestions. I made an account on Mailgun and managed to use a Mailgun plugin for Craft 3 to set up the API key interaction in the settings. The "test" email is working fine however I'm not sure how to make it interact with the plugin "Contact Form" or how to make write my contact form now that the email settings seem to be working. Any advice om this? Thanks! – Nicolas Barse Jun 10 '18 at 18:59
  • Just to confirm—have you set the required Contact Form preferences in the Control panel or via a config file? github.com/craftcms/contact-form#overriding-plugin-settings – August Miller Jun 11 '18 at 23:29
  • Internally, the Contact Form plugin uses Craft's mailer service, which acts as a bridge between any calls to send mail and the provider itself—this is just to say that there shouldn't be any additional Contact Form configuration necessary specific to Mailgun. – August Miller Jun 11 '18 at 23:32

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.