Tell me please. You need to make a form that will send an email data to email. I use joomla .
Created the file send_mail.php in the folder with the template.
Content:
<? //defined('_JEXEC') or die; require_once '/libraries/joomla/mail/mail.php'; header("Content-type: text/plain; charset=utf-8"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); $mailer = JFactory::getMailer(); $config = JFactory::getConfig(); $sender = array($config->getValue('mailfrom'), $config->getValue('fromname') ); $mailer->setSender($sender); $mailer->addRecipient('test@gmail.com'); $body = "Имя: ".$_POST['name'].'; Телефон: '.$_POST['phone']; $mailer->setSubject('Нужна бесплатная консультация'); $mailer->setBody($body); $send = $mailer->Send(); if ($send !== true) { echo 'Error sending email: '.$send->message; } else { echo 'Mail sent'; } ?> I send the request using ajax. When you click on the button. In the console I see http://site.ru/templates/test/send_mail.php 500 (Internal Server Error)
Why? where is the mistake?