You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP.
So if you are using XAMPP then you can easily send mail from localhost.
for example you can configure C:xamppphpphp.ini
and c:xamppsendmailsendmail.ini
for gmail to send mail.
in C:xamppphpphp.ini
find extension=php_openssl.dll
and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.
in php.ini file find [mail function]
and change
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
Now Open C:xamppsendmailsendmail.ini
. Replace all the existing code in sendmail.ini with following code
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
Now you have done!! create php file with mail function and send mail from localhost.
PS: don't forgot to replace my-gmail-id and my-gmail-password in above code.
Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:xamppmailtodiskmailtodisk.exe"
in the php.ini file
Also remember to restart the server using the XAMMP control panel so the changes take effect.
For gmail please check https://support.google.com/accounts/answer/6010255 to allow access from less secure apps.
To send email on Linux (with sendmail package) through Gmail from
localhost please check PHP+Ubuntu Send email using gmail form
localhost.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…