如何在 Windows 7 中运行 PHP 邮件脚本


How to run PHP mail scripts in Windows 7?

我正在尝试使用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 从我的本地计算机发送电子邮件?

在观看了这么多YouTube视频和博客之后,这对我有用:

  1. 确保您的SMTP服务状态显示已激活 ->转到此URL以获得一个漂亮的演示。

  2. 转到此 URL,使用您将用于测试 php 电子邮件的 gmail 帐户登录,然后在"安全"选项卡中,找到"访问安全性较低的应用程序",然后单击启用(您可以随时在 php 电子邮件测试后再次禁用它(。

  3. 从一个全新的php.ini文件开始(希望您复制了原始php.ini(。这样做的原因是,您将拥有一个未被篡改的php.iniphp.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"
    
  4. 那么sendmail.ini必须如下 - 我基本上在这里复制了整个东西。 在它说your.email.gmail输入您自己的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=