如何使用PHPmailer在xampp localhost中发送电子邮件?

如何使用PHPmailer在xampp localhost中发送电子邮件?,xampp,phpmailer,phpinfo,Xampp,Phpmailer,Phpinfo,我附上了两个不同的PDF文件mnlocalXampp和rnlocalXampp,它们是两台不同PC的phpinfo。我检查了这两个信息,似乎它们都有相同的信息,使用相同版本的PHP,但我收到的电子邮件是mnlocalXampp,而不是rnlocalXampp。我也在这两个版本中激活了openssl,但我仍然没有在rnlocalxampp中收到电子邮件。任何人都可以看看这两个文件,让我知道什么不同的文件和如何配置 <?php require 'email_class/class.phpma

我附上了两个不同的PDF文件mnlocalXampp和rnlocalXampp,它们是两台不同PC的phpinfo。我检查了这两个信息,似乎它们都有相同的信息,使用相同版本的PHP,但我收到的电子邮件是mnlocalXampp,而不是rnlocalXampp。我也在这两个版本中激活了openssl,但我仍然没有在rnlocalxampp中收到电子邮件。任何人都可以看看这两个文件,让我知道什么不同的文件和如何配置

<?php
 require 'email_class/class.phpmailer.php';
 $mail = new PHPMailer;
 $mail->IsSMTP();          //Sets Mailer to send message using SMTP
 $mail->Host = 'cp-in-10.webhostbox.net';    //Sets the SMTP hosts of your Email hosting, this for Godaddy
 $mail->Port = '465';                //Sets the default SMTP server port
 $mail->SMTPAuth = true;       //Sets SMTP authentication. Utilizes the Username and Password variables
 $mail->Username = 'mn@infotech.com';    //Sets SMTP username
 $mail->Password = 'xxxxxxx';          //Sets SMTP password
 $mail->SMTPSecure = 'ssl';          //Sets connection prefix. Options are "", "ssl" or "tls"
 $mail->From = 'mn@infotech.com';          //Sets the From email address for the message
 $mail->FromName = "mn";        //Sets the From name of the message
 $mail->AddAddress("m@infotech.com");    //Adds a "To" address
 $mail->AddCC("m@infotech.com");  //Adds a "Cc" address
 $mail->WordWrap = 50;       //Sets word wrapping on the body of the message to a given number of characters
 $headers = "MIME-Version: 1.0" . "\r\n";
 $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
 $mail->IsHTML(true);              //Sets message type to HTML       
 $mail->Subject = 'Project CMS';       //Sets the Subject of the message
 $mail->Body = $message; //An HTML or plain text message body
 $mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf'); 
 $mail->Send(); ?>
上面的示例代码是mnlocaXampp的电子邮件配置。对于rnlocalXampp,我使用不同的端口号:25,托管,启用SSL


提前感谢

很难知道从哪里开始

您的代码基于一个过时的示例,并且使用的是PHPMailer的旧版本,因此,请将您的代码基于提供的示例

在使用$doc之前,您没有定义它

如果您试图发送本地文件,addStringAttachment是错误的方法;改用addAttachment

$headers的定义毫无意义

抄送你已经发送到的地址没有意义

检查任何地方都没有错误


解决上述一些问题可能有助于解决您的问题。

谢谢您的回复。。请检查我随附的两份phpinfo文档的mnlocalXampp和rnlocalXampp链接。实际上,我在代码中没有错误,我也在使用最新版本的PHPmailer。问题是,我在一个本地主机mnlocalXampp中接收电子邮件,而在另一个本地主机mnlocalXampp中我没有接收电子邮件,这是我的客户端rnlocalXampp pc。我认为他们可能使用代理,这就是为什么电子邮件没有从我的客户端pc发送。否。您需要在问题中包含所有相关信息。当代码中有基本错误时,查看PHP配置没有任何意义。您没有使用最新的PHPMailer;最新版本无法与您的代码一起运行。