我正在尝试使用xampp在本地计算机(Windows 7)中运行PHP邮件脚本。我可以成功运行PHP邮件表单但在发送电子邮件时显示此消息 -
**Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\mail\sendeail.php on line 146**
如何解决此问题,或者是否可以使用xampp以其他方式从本地计算机发送电子邮件?
答案 0 :(得分:0)
观看了如此多的YouTube视频和博客后,这对我有用:
确保您的SMTP服务状态显示为ACTIVATED - >转到this URL以获得一个不错的演示。
转到this URL,使用您将用于测试您的php电子邮件的Gmail帐户登录,然后在“安全”标签中找到"访问不太安全的应用&#34 34;然后单击启用(您可以在php电子邮件测试后再次禁用它。)
从一个全新的php.ini
文件开始(希望您复制了您的orignal php.ini
)。这样做的原因是,您将php.ini
没有被篡改。 php.ini
中的以下这些行必须是注释(具有前导;
)或未注释(不具有前导;
),这是至关重要的):
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
;SMTP = localhost
;smtp_port = 25
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
extension=php_openssl.dll
php.ini
你独自离开的所有人。
因此,请仔细检查这些行是否已注释(具有前导;
):
;SMTP= local host
;smtp_port = 25
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
然后sendmail.ini
必须如下 - 我基本上复制了整件事。如果在您自己的Gmail地址中输入your.email.gmail
,则输入相同的密码:
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL
smtp_ssl=auto
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
;default_domain=mydomain.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
;debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=your.email@gmail.com
auth_password=your email password
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.
pop3_server=
pop3_username=
pop3_password=
; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content
force_sender=
; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content
force_recipient=
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required
hostname=