How can I use fake sendmail with SwiftMailer on Windows?

一笑奈何 提交于 2019-12-05 16:31:55

You need to use right transport:

$transport = Swift_SendmailTransport::newInstance('C:\usr\lib\sendmail.exe');

UPDATE Use this line:

$transport = Swift_MailTransport::newInstance();

Assuming you have installed the fake sendmail into a local directory like:

C:\wamp64\bin\sendmail\sendmail.exe

Edit your php.ini file like this:

sendmail_path = "C:\wamp64\bin\sendmail\sendmail.exe -t"

Edit your sendmail.ini file like this:

smtp_server=localhost
smtp_port=25
smtp_ssl=none

then use swiftmailer SMTP transport like this:

$transport = new Swift_SmtpTransport('localhost', 25);
  • Swift_SendmailTransport is designed only for (Linux/UNIX) executable.

For Laravel Users

the process is the same but you also need to edit your .env file like this:

MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=myemail@example.com
MAIL_FROM_NAME="My Name"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!