Php 如何从本地主机发送smtp邮件
我总是在试图从本地主机发送电子邮件时收到此消息 SMTP错误:无法连接到SMTP主机。无法发送消息。 邮件程序错误:SMTP错误:无法连接到SMTP主机 下面是我的代码:请帮忙Php 如何从本地主机发送smtp邮件,php,email,smtp,Php,Email,Smtp,我总是在试图从本地主机发送电子邮件时收到此消息 SMTP错误:无法连接到SMTP主机。无法发送消息。 邮件程序错误:SMTP错误:无法连接到SMTP主机 下面是我的代码:请帮忙 打开php.ini。对于XAMPP,它位于C:\XAMPP\php\php.ini中。了解您是在使用WAMP还是LAMP服务器。 注意:备份php.ini文件 在php.ini文件中搜索[mail function] You can find like below. [mail function] ; For Win
打开php.ini
。对于XAMPP,它位于C:\XAMPP\php\php.ini
中。了解您是在使用WAMP还是LAMP服务器。
注意:备份php.ini
文件
在php.ini文件中搜索[mail function]
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
将localhost更改为ISP的smtp服务器名称。无需更改smtp\u端口
。把它设为25。更改sendmail\u from
frompostmaster@localhost
发送至您的域电子邮件地址,该地址将用作发件人地址
所以对我来说,它会变成这样
[mail function]
; For Win32 only.
SMTP = smtp.example.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@example.com
重新启动XAMPP或WAMP(apache服务器),以便更改开始工作
现在尝试使用mail()
函数发送邮件
mail("example@example.com","Success","Great, Localhost Mail works");
邮件将被发送到example@example.com从主题行为“Success”和正文为“Great,localhost Mail works”的localhost中,您可以添加这一行
$mail->SMTPSecure=“ssl”代码>
之后
$mail->SMTPAuth = true;
您安装了邮件服务器?邮件服务器?没有。我只是在本地主机上运行此代码。我认为这是不可能的?请阅读代码commentshow以安装邮件服务器?我认为这是由于smtp端口号配置不正确造成的。