2017-02-02 663 views
-4

我在从本地主机发送电子邮件时遇到了一些问题,并且需要您的帮助。这是错误消息我已经越来越:使用本地主机在php中发送电子邮件

警告:电子邮件(): “sendmail_from” 没有在php.ini或设置自定义 “发件人:” 头丢失在C:\ XAMPP \ htdocs中\电子邮件\ send_mail.php上线22

This is my php.ini file

This is my sendmail.php file

This is my sendmail.ini file

请协助

+2

无法从'localhost'发送邮件。您必须使用正确设置的服务器。 – Harish

+0

@Harish Kommuri;您可以使用'phpmailer'从'localhost'发送邮件 –

+3

不要发布代码图片。正确发布并格式化 – Takarii

回答

0

您的邮件格式错误

mail($email_address,$subject,$msg,$header); 
0

要使用本地主机,你需要配置本地主机发送电子邮件发送电子邮件。

将以下步骤发送使用本地主机电子邮件xamppsendmail

您可以从本地主机和sendmail包发送邮件,sendmail的包在XAMPP inbuild。所以,如果您使用XAMPP,那么您可以轻松地从本地主机发送邮件。

例如,您可以配置C:\xampp\php\php.inic:\xampp\sendmail\sendmail.ini以供gmail发送邮件。

in C:\xampp\php\php.ini find extension=php_openssl.dll并从该行的开头删除分号以使SSL适用于localhost的gmail。在php.ini文件

找到[mail function]和改变

SMTP=smtp.gmail.com 
smtp_port=587 
sendmail_from = [email protected] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

替换sendmail.ini所有现有的代码与下面的代码

smtp_server=smtp.gmail.com 
smtp_port=587 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=your-gmail-password 
[email protected] 
Then you are done :) 

记得使用XAMMP控制面板等等的变化重新启动服务器生效。快乐编码:)

顺便说你的邮件功能是不正确

应该

mail($to,$subject,$message,$headers);

相关问题