Sending emails with october. The emails are not coming

Hello, I am trying to send an email from a contant form.
There are no errors in the console, but the emails are not being sent.

I use October CMS v2.x / PHP 7.3.33
settings (driver, host…) in maill.php correct

this is what my form code looks like:

 < form class="contact-form" data-request="onSend()" method="post" action="#" data-request-success="alert('We have recieved your email.. we\'ll get back to you shortly')" data-request-error="alert(jqXHR.responseText);" novalidate="novalidate"> ... < /form>

to the code tab:

function onSend(){

    $contact_name = post('contact_name');
    $contact_email = post('contact_email');
    $contact_phone = post('contact_phone');
    $contact_message = post('contact_message'); 
    $to = post('mail_to');
    $params = compact('contact_name','contact_email','contact_phone');
    Mail::sendTo($to, 'contactform', $params);
    return true;

“mail_to” - the value is indicated below by the form:

< input type="hidden" name="mail_to" value="">

I also have a mail template created:

I tried to create templates with different names (‘backend::mail.contactform’),
tried Mail::send() instead of Mail::sendTo() ;
tried data-request=“onSend()”/ data-request=“onSend” / data-request=“{{ SELF }}::onSend”

I also calling the $.request(‘onSend’) method a js file.

But my message is not coming :frowning:
what am I doing wrong?

Hi and welcome @elenamalets

The first thing to try here is to set the mail driver to use log. Then send the message and see if it appears in the Event Log area.

  • If the mail arrives at the log: We know it is a problem with the configured mail provider.

  • If the mail does not appear in the log: There is something wrong with the code.

I hope this helps.

There is something wrong with the code.

Because when creating an admin, an email arrives (and the template is correct):

If the issue is code related, do you see any errors in the javascript console, developer tools in the browser?

If someone faces a similar problem, I hope this video will help you. ( Making Websites With October CMS - Part 18 - Creating Contact Form - YouTube )

I couldn’t find the error, so I decided to use the plugin (Small Contact Form plugin - October CMS), and with its help my form works.

1 Like