本文介绍了xampp 目录中不存在 Sendmail 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to send email from localhost but somehow mail is not being send to any email address. I am trying to configure email from localhost and found some solution which are pointing me to configure with sendemail server which is \xampp\sendmail\sendmail.exe. My problem is that I can not found sendmail folder in my xampp directory. So can not configure sendmail.

我使用的是 xampp v3.2.1

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

Can please anyone tell me that why I don't have sendmail folder in xampp dir?

推荐答案

你必须有SMTP服务器,这样你才能发送邮件
另一种解决方案是使用外部工具,例如 gmail

You must have SMTP Server, so you can send mails
Alternative solutions is to use externals one, like gmail for example

首先你应该有一个有效的 gmail 凭据,然后转到 php.ini 并按如下方式配置它:

First you should have a valid gmail credetials, after that go to php.ini and configure it as follow :

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

重新启动您的 Web 服务器并尝试使用经典的 php mail()功能

Restart your web server and try with the classic php mail() function

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

Here is my yml SMTP Server configuration that i have used for a symfony project :

parameters:
    mailer_transport: gmail
    mailer_host     : 127.0.0.1
    mailer_user     : [email protected]
    mailer_password : ***my_gmail_password_secret***
    locale          : en

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

You can setup your own local SMTP Server local SMTP Server

__编辑__

尝试使用 PHPMailer:PHPMailer - 功能齐全的电子邮件创建
它的好处是,它可以让您调试导致使用 gmail smtp 服务器发送邮件的问题

Try with PHPMailer : PHPMailer - A full-featured email creation
And the good thing with it, that it will let you debug what is causing troubles with sending mails using gmail smtp server

第一件事:你支持代理吗?如果是这种情况,则必须配置HTTP_PROXY/HTTPS_PROXY 环境变量
您可以在此处这里

First thing : are you behind proxy ? if it's the case, you have to configure the HTTP_PROXY/HTTPS_PROXY environment variables
You can find useful documentations here and here

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

Now, you can create a php test script that you can launch directly via commands line or using a web server

<?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('[email protected]', 'Anis Halayem');
$mail->Subject    = "Test Send Mails";
$mail->MsgHTML($body);
$address = "[email protected]";
$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!";
}

这篇关于xampp 目录中不存在 Sendmail 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 15:20