0

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

4

1 回答 1

0

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

  1. 确保您的 SMTP 服务状态显示为 ACTIVATED --> 转到此 URL以获得一个不错的演示。

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

  3. 从一个全新的php.ini文件开始(希望您制作了原始文件的副本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"
    
  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=
    
于 2014-10-18T08:24:30.320 回答