如何在xampp上使用phpMail发送邮件

如何在xampp上使用phpMail发送邮件,php,xampp,smtp,phpmailer,sendmail,Php,Xampp,Smtp,Phpmailer,Sendmail,我一直在尝试在xampp上使用php mailer发送邮件,但我确实收到了以下错误消息: 无法发送消息。邮件程序错误:以下发件人地址失败:xxxx2@gmail.com:在未连接的情况下呼叫邮件 求你了,我需要你帮我解决这个问题。 这是我的密码 <?php require( 'class.phpmailer.php' ); $mail = new PHPMailer; $mail->IsSMTP(); $mail->SMTPAuth = true; $mail

我一直在尝试在xampp上使用php mailer发送邮件,但我确实收到了以下错误消息: 无法发送消息。邮件程序错误:以下发件人地址失败:xxxx2@gmail.com:在未连接的情况下呼叫邮件

求你了,我需要你帮我解决这个问题。 这是我的密码

<?php
require( 'class.phpmailer.php' );

  $mail = new PHPMailer;
  $mail->IsSMTP();
  $mail->SMTPAuth = true;
  $mail->Host = "tls://smtp.gmail.com";
  $mail->Port = 25;
  $mail->Username = "xxxx@gmail.com";
  $mail->Password = "xxxxx";
  //Sending the actual email
  $mail->setFrom('xxxx2@gmail.com', 'Aaron');
  $mail->addAddress('xxxx2@gmail.com', 'Aaron');     // Add a recipient
  $mail->isHTML(false);                                  // Set email format to HTML
  $mail->Subject = 'Calculation form results from ';
  $mail->Body = 'testing...';

  if(!$mail->send()) {
    echo 'Message could not be sent. ';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    exit;
  }
?>
照抄

照抄


我尝试使用Composer和github,但无法通过xampp使用最新版本的phpmailer来处理我的测试php电子邮件。当我在localhost上运行该程序时,它不断崩溃,因为电子邮件代码正在寻找php mailer类。 所以我回到谷歌,忽略了composer,下载了一个普通的php mailer 5.2.0压缩包,并将该压缩包直接解压缩到我的“websiteX”测试文件夹中,该文件夹位于xampp的htdocs中

在我的“websiteX”文件夹中,我有testmail.php文件和phpmailer解压文件夹,其中包含class.phpmailer,它在我的案例中实际工作

我花了一个星期的时间闲逛,但现在我有xampp php电子邮件完美地进入我的测试gmail帐户。我也使用chrome和记事本+

有趣的是,虽然Gmail硬反弹了php邮件,但我的php邮件也可以使用php邮件命令,这并不好。上周我做的第一件事就是让Mercury mail包含在xampp中。我遵循这个链接,并设法让xampp与gmail通信,这太棒了


祝你编码顺利

我尝试使用Composer和github,但无法通过xampp使用最新版本的phpMail来处理我的测试php电子邮件。当我在localhost上运行该程序时,它不断崩溃,因为电子邮件代码正在寻找php mailer类。 所以我回到谷歌,忽略了composer,下载了一个普通的php mailer 5.2.0压缩包,并将该压缩包直接解压缩到我的“websiteX”测试文件夹中,该文件夹位于xampp的htdocs中

在我的“websiteX”文件夹中,我有testmail.php文件和phpmailer解压文件夹,其中包含class.phpmailer,它在我的案例中实际工作

我花了一个星期的时间闲逛,但现在我有xampp php电子邮件完美地进入我的测试gmail帐户。我也使用chrome和记事本+

有趣的是,虽然Gmail硬反弹了php邮件,但我的php邮件也可以使用php邮件命令,这并不好。上周我做的第一件事就是让Mercury mail包含在xampp中。我遵循这个链接,并设法让xampp与gmail通信,这太棒了


祝你编码顺利

根据phpmailer的教程,您应该使用require'phpmailerautoad.php';。此外,它应该是$mail=new PHPMailer;。你的端口错了。请为TLS尝试587。$mail->Host=tls://smtp.gmail.com; $邮件->端口=587;仍然是相同的错误根据phpmailer的教程,您应该使用require'phpmailerautoad.php';。此外,它应该是$mail=new PHPMailer;。你的端口错了。请为TLS尝试587。$mail->Host=tls://smtp.gmail.com; $邮件->端口=587;还是同样的错误如果它有效,你能接受它作为正确答案吗?如果它有效,你能接受它作为正确答案吗?
//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "username@gmail.com";

//Password to use for SMTP authentication
$mail->Password = "yourpassword";

//Set who the message is to be sent from
$mail->setFrom('from@example.com', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('whoto@example.com', 'John Doe');