简体   繁体   中英

PHP mail() win64

Is it possible to use PHP mail() on localhost in 64-bit Win10?
I use xampp to run localhost and tried to use this function, but it returns error Socket Error #10060<EOL>Connection timed out .
I used this configuration on 32-bit Win and there was no problem, mails were sent without any errors.

Any solutions?

To send mail in gmail account ->In sendmail(inside wamp folder) folder open file “sendmail.ini” in notepad for editing

Change the below line in this file smtp_server=smtp.gmail.com //if ur using gmail id

a) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMP or LAMP server. Note : Make a backup of php.ini file

b) Search [mail function] in the php.ini file.

You can find like below.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25


; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost


Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address..

So for me, it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.example.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@example.com


c) Restart the XAMPP or WAMP(apache server) so that changes will start working.

d) Now try to send the mail using the mail() function ,

mail("example@example.com","Success","Great, Localhost Mail works");

Mail will be sent to "example@example.com" from the localhost with Subject line "Success" and body "Great,Localhost Mail works"

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