Use Gmail SMTP server

April 2018

Use Gmail SMTP server


I tried sending emails with the mail () function in php.ini like this:

[Mail function]
; For Win32 only.
SMTP = / * (this is the address of my ISP's SMTP server)
smtp_port = 25

but mail () function generates the following error: Warning: mail () [function.mail]: SMTP server response: 451
means that: 451 - The command has-been aborted due to a server error.
so I would like to know how to use gmail smtp server if possible.


My message was very clear, I tried with the smtp of my ISP (topnet) but it did not work because it seems to me that the mail () function does not work for
this server (SMTP server response: 451), so I wanted to know what it is possible to use the SMTP server for gmail, and I just found out now that it's possible but after some configuration, this is the Solution:
  • Download msmtp:
  • Install msmtp: I chose to resume the installation of Apache to install msmtp. So I extract the binary archive msmtp.exe previously downloaded and put it in C: \ AMP \ apache \ bin \
  • Configure msmtp: I created a file C: \ AMP \ apache \ conf \ msmtp.conf this way:

tls it
tls_starttls it
tls_trust_file C: \ AMP \ apache \ conf \ ca-roots.crt

default account
port 587
auth is
password leMotDePasseCorrespondant
logfile C: \ AMP \ apache \ logs \ msmtp.log

tls_trust_file is required to validate the SSL connection required by Gmail. Geotrust download the file "Equifax Secure Certificate Authority (Base-64 encoded X.509)" I've moved / renamed C: \ AMP \ apache \ conf \ ca-roots.crt.
  • Reconfigure PHP by editing the php.ini file. Comment lines SMTP and sendmail_from then add:

sendmail_path = "C: \ AMP \ apache \ bin \ msmtp.exe - file C: \ AMP \ apache \ conf \ msmtp.conf-t"
  • Restart Apache if PHP is running as a module and you do your testing in this SAPI
  • Test


Solved by azerty123
Published by aakai1056. Latest update on December 7, 2010 at 06:21 AM by aakai1056.
This document, titled "Use Gmail SMTP server ," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Gmail - Recover a Mail sent by error
Gmail - Restore your contacts