【问题标题】:Sendmail folder does not exist in xampp directory?xampp目录中不存在Sendmail文件夹?
【发布时间】:2015-11-30 14:15:48
【问题描述】:

我正在尝试从本地主机发送电子邮件,但不知何故,邮件没有发送到任何电子邮件地址。我正在尝试从 localhost 配置电子邮件,并找到了一些解决方案,这些解决方案指向我使用 sendemail 服务器进行配置,即 \xampp\sendmail\sendmail.exe。我的问题是在我的 xampp 目录中找不到 sendmail 文件夹。所以不能配置sendmail。

我正在使用 xampp v3.2.1

谁能告诉我为什么我在 xampp 目录中没有 sendmail 文件夹?

【问题讨论】:

标签: php apache email localhost sendmail


【解决方案1】:

您必须有 SMTP 服务器,才能发送邮件
替代解决方案是使用外部设备,例如 gmail

首先你应该有一个有效的 gmail 凭证,然后去 php.ini 并配置它如下:

[mail function]
SMTP      = ssl://smtp.gmail.com
smtp_port = 465
username  = YOUR_GOOGLE_USERNAME
password  = YOUR_GOOGLE_PASSWORD

重新启动您的网络服务器并尝试使用经典的 php mail() 函数

这是我用于 symfony 项目的 yml SMTP 服务器配置:

parameters:
    mailer_transport: gmail
    mailer_host     : 127.0.0.1
    mailer_user     : anis.halayem@gmail.com
    mailer_password : ***my_gmail_password_secret***
    locale          : en

您可以设置自己的本地 SMTP 服务器local SMTP Server

__EDIT__

尝试使用 PHPMailer:PHPMailer - A full-featured email creation
它的好处是,它可以让您调试导致使用 gmail smtp 服务器发送邮件的问题

第一件事:你在代理后面吗?如果是这种情况,则必须配置HTTP_PROXY/HTTPS_PROXY 环境变量
您可以找到有用的文档 herehere

现在,您可以创建一个 php 测试脚本,您可以通过命令行或使用 Web 服务器直接启动它

<?php
require_once    ('PHPMailer-master/class.phpmailer.php');
require_once    ('PHPMailer-master/class.smtp.php');

$mail               = new PHPMailer();
$body               = "<h1> Sending HTML Mails using gmail</h1><p>it's great !!</p>";
$mail->IsSMTP();                                        // telling the class to use SMTP
$mail->SMTPDebug    = 1;                                // enables SMTP debug information (for testing)
$mail->SMTPAuth     = true;                             // enable SMTP authentication
$mail->SMTPSecure   = "tls";                            // sets the prefix to the servier
$mail->Host         = "smtp.gmail.com";                 // sets GMAIL as the SMTP server
$mail->Port         = 587;                              // set the SMTP port for the GMAIL server

$mail->Username     = "YOUR_GMAIL_ACCOUNT"  ;           // GMAIL username
$mail->Password     = 'YOUR_GMAIL_PASSWORD' ;           // GMAIL password

$mail->SetFrom('VALID_USER@gmail.com', 'Anis Halayem');
$mail->Subject    = "Test Send Mails";
$mail->MsgHTML($body);
$address = "VALID_USER@gmail.com";
$mail->AddAddress($address, "USER NAME");

// $mail->AddAttachment("images/phpmailer.gif");        // attachment
// $mail->AddAttachment("images/phpmailer_mini.gif");   // attachment

if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} 
else {
    echo "Message sent!";
}

【讨论】:

  • "您可以设置自己的本地 SMTP 服务器本地 SMTP 服务器" - 我可以不设置本地 SMTP 服务器吗?
  • @RupamDatta 是的,当然:只需使用像 gmail 这样的外部 SMTP 服务器,然后按照 php.ini 文件中的配置进行设置跨度>
  • 我尝试使用 gmail 配置,但无法发送电子邮件。我收到连接错误。我可以和你分享我到目前为止所尝试的。
  • 我收到此错误:2016-02-09 08:50:56 SMTP 错误:无法连接到服务器:没有路由到主机 (65) 2016-02-09 08:50: 56 SMTP 连接()失败。 github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 邮件程序错误:SMTP 连接()失败。 github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  • 所以,我认为您应该配置您的HTTP_PROXY 环境变量,确保您的设置正确:您必须能够正确ping google.com,然后再进一步......
【解决方案2】:

我遇到了同样的问题。
这很容易解决。
只需按照以下步骤操作:
首先确保您使用的是 Xampp v3.2.2,因为这是我正在使用并且我知道的版本。

  1. 复制并粘贴“您”在电脑上任何位置的 htdocs 文件夹中创建的所有文件。(这样它们就不会被删除)。
  2. 卸载 Xampp。
  3. 然后重新安装 Xampp,但是这一次,当它询问“选择组件”时,不要取消选中列表中的“Fake Sendmail”选项。
  4. 然后按照正常流程进行。

而且,你已经完成了。 Sendmail 会正常安装。

【讨论】:

    猜你喜欢
    • 2013-05-28
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    • 1970-01-01
    • 2021-08-29
    相关资源
    最近更新 更多