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="elenamalets1999@gmail.com">
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
what am I doing wrong?