I get this error whenever someone submits the form:
Fatal error: Uncaught Nette\Mail\SendException: Unable to send email.
Here is my code:
if ($form->isSubmitted()) {
$values = $form->getValues();
$mail = new \Nette\Mail\Message;
$mail->setFrom('[email protected]')
->addTo('[email protected]')
->setSubject('New contact')
->setHtmlBody('Hi<br> you\'ve got new message.<br> from: ' . $values['name'] . '<br> email: ' . $values['email'] . '<br> Message:' . $values['message']);
$mailer = new Nette\Mail\SendmailMailer();
$mailer->send($mail);
how i set SMTP for gmail
public $defaults = [
'smtp' => false,
'host' => null,
'port' => null,
'username' => null,
'password' => null,
'secure' => null,
'timeout' => null,
'clientHost' => null,
];
SendmailMaileruses php functionmail()and it has to be configured inphp.inito work, see https://www.php.net/manual/en/mail.configuration.phpSimplest way of using smtp with Nette is
SmtpMailerAlso don't forget to set correct configuration, gmail will not accept empty credentials. Something like: