简体   繁体   中英

PHP SMTP not sending email in Laravel Valet

I have an issue when trying to send email using mailtrap configuration in codeigniter. I am using Codeigniter in Laravel Valet. Recently wanted to try Laravel Valet as a development environment, I had been using vagrant box before. If I use the same code in Vagrant, emails are sent with no issue, but when I use this same code with Valet it fails with the following error.

ERROR - 2017-10-15 23:36:45 --> 220 mailtrap.io ESMTP ready, hello: 501 5.5.4 Invalid argument, The following SMTP error was encountered: 501 5.5.4 Invalid argument, Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.Date: Sun, 15 Oct 2017 23:36:45 +0000

My $config configuration in Codeigniter for mailtrap is the following.

$config = array(
'protocol' => 'smtp',
'mailpath' => '/usr/sbin/sendmail',
'smtp_host' => 'smtp.mailtrap.io',
'smtp_port' => 2525,
'smtp_user' => 'mailtrap_user',
'smtp_pass' => 'mailtrap_pass',
'crlf' => "\r\n",
'newline' => "\r\n"

);

This configuration works with no issues when I am working from Vagrant. I have checked several threads regarding OpenSSL issues but it seems like Valet configuration is ok. This is part of the phpinfo() data when using Valet:

PHP Version 7.1.10
SSL Version OpenSSL/1.0.2l
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.2l 25 May 2017
OpenSSL Header Version OpenSSL 1.0.2l 25 May 2017
Openssl default config /usr/local/etc/openssl/openssl.cnf
curl
SSL Version OpenSSL/1.0.2l

And on the Vagrant side, this is part of the phpinfo() data

PHP Version 7.0.5-2
SSL Version OpenSSL/1.0.1f
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.2g 1 Mar 2016
OpenSSL Header Version OpenSSL 1.0.2g 1 Mar 2016
Openssl default config /usr/lib/ssl/openssl.cnf
curl
SSL Version OpenSSL/1.0.1f

I have gone through some of the configuration in the php.ini files and phpinfo() data but have not been able to spot a difference. I do not know if someone has dealt with this issue before that can point me in the right direction. In case more info is needed please let me know. I really appreciate all of your time and help.

The issue is with mailtrap.io it self. If your configuration is actually like this below.

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=31466861b7bXXX
MAIL_PASSWORD=fe2b6503618XXX
MAIL_ENCRYPTION=null

I tested with two separate framework to proof this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM