Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

almazik's avatar

[HELP] email doesn't get sent with gmail smtp

Hi everyone.

I'm trying to send email from my application but getting the following error: Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 kz7sm4622758lac.10 - gsmtp "

my app/config.mail.php looks like this:


'driver' => 'smtp', 'host' => 'smtp.gmail.com', 'port' => 587, 'from' => array('address' => 'xmalinkoff@gmail.com', 'name' => 'Andrew Malinkoff'), 'encryption' => 'tls', 'username' => 'username@gmail.com', 'password' => 'my pass', 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => false,

Any thoughts?

credentials are correct, I tried to use different ones several times

0 likes
14 replies
xingfucoder's avatar
Level 14

You need to authorize the external application use of gmail, I think.

Follow the next steps and authorize to make it:

  • First, go to your Google Account Management page
  • Under the Security options, click Edit link of Authorizing applications & sites

Hope it helps you.

4 likes
almazik's avatar

Well, it worked on local environment, but not going to on forge... Getting the same error

1 like
xingfucoder's avatar

May be you need to create a token for use within forge.

Any forge user maybe help in a better way.

JillzTom's avatar

Best solution is to use http://mandrill.com/
You don't have to compromise with your Gmail security. Every Mandrill account comes with 2,000 free trial sends.

muragijimana's avatar

Why can you buy service while there is other free service please explain to me?

2 likes
stevewolfe555's avatar

Hi,

Just change your 'driver' => 'smtp', to 'driver' => 'sendmail',

All configurations are correct. Just need to change driver 'smtp' to 'sendmail'. It's working.

For copy paste ;)

'driver' => 'sendmail', 'host' => 'smtp.gmail.com', 'port' => 587, 'from' => array('address' => '[email protected]', 'name' => 'Andrew Malinkoff'), 'encryption' => 'tls', 'username' => '[email protected]', 'password' => 'my pass', 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => false,

6 likes
lucasmartins's avatar

Hi @stevewolfe555 , Thankyou very much!

I changed the driver to 'sendmail' and it worked.

But the emails are falling in the spam box, do you know about it?

Regards, Lucas Martins.

rinkesh-prajapat's avatar

Error is:- stream_socket_enable_crypto():

SSL operation failed with code 1. OpenSSL Error messages:

error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

MuzammilRafay's avatar

when i changed mail_driver=sendmail it gives me this error proc_open() has been disabled for security reasons.

Please or to participate in this conversation.