SendmailMailer – Unable to send email

Yeti
Member | 8
+
0
-

Hello everyone.

I have just been studying the docs regarding sending an email for account verification but I am getting the error Nette\Mail\SendException Unable to send email.

My code is as follows and I am running it on my laptop via xampp until I am ready to upload it to a server

 $mail = new Nette\Mail\Message;
 $mail->setFrom('John <john@example.com>')
      ->addTo('peter@example.com')
      ->setSubject('Test')
      ->setBody("Test")

 $mailer = new Nette\Mail\SendmailMailer;
 $mailer->send($mail);

Is there another step I am missing?

Marek Bartoš
Nette Blogger | 1244
+
+2
-

SendmailerMailer uses PHP function mail() which has to be configured in php.ini section [mail function] in order to work.
Usually it is better to setup the SmtpMailer.

Yeti
Member | 8
+
0
-

Marek Bartoš wrote:

SendmailerMailer uses PHP function mail() which has to be configured in php.ini section [mail function] in order to work.
Usually it is better to setup the SmtpMailer.

Thanks a lot, the SmtpMailer worked a treat.