Php SMTP错误,我不知道';我不知道为什么
我真的希望有人能帮我。我不知道我的问题是什么原因。但有一个错误是 SMTP错误:无法连接到SMTP主机。邮件错误->SMTP错误: 无法连接到SMTP主机 提前谢谢你,谢谢你的帮助Php SMTP错误,我不知道';我不知道为什么,php,email,gmail,Php,Email,Gmail,我真的希望有人能帮我。我不知道我的问题是什么原因。但有一个错误是 SMTP错误:无法连接到SMTP主机。邮件错误->SMTP错误: 无法连接到SMTP主机 提前谢谢你,谢谢你的帮助 <?php require_once('phpmailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->CharSet = "utf-8"; $mail->IsSMTP(); $mail-&
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->CharSet = "utf-8";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Username = "kurokonobasket189@gmail.com";
$mail->Password = "vanishingdrive";
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = "465";
$mail->setFrom('kurokonobasket189@gmail.com', 'Francis');
$mail->AddAddress('astigvargas189@yahoo.com', 'Arnold');
$mail->Subject = 'using PHPMailer';
$mail->IsHTML(true);
$mail->Body = 'Hi there ,
<br />
this mail was sent using PHPMailer...
<br />
cheers... :)';
if($mail->Send())
{
echo "Message was Successfully Send :)";
}
else
{
echo "Mail Error - >".$mail->ErrorInfo;
}
?>
从下载最新版本 用这个,
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@gmail.com'; // your domain username
$mail->Password = 'pass'; // your address password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('test@gmail.com', 'Mailer'); //your domain addres
$mail->addAddress('bilisim_0@outlook.com', 'Joe User'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('test@gmail.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
从下载最新版本
用这个,
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@gmail.com'; // your domain username
$mail->Password = 'pass'; // your address password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('test@gmail.com', 'Mailer'); //your domain addres
$mail->addAddress('bilisim_0@outlook.com', 'Joe User'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('test@gmail.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
很明显它无法连接,可能端口被阻塞了?你查过谁负责网络了吗?对不起,是哪个网络?我如何检查?请包括两个文件<代码>require_once('class.phpmailer.php');需要一次_(“class.smtp.php”)代码>Irfan,有一个错误提示。require_once(class.phpmailer.php):打开流失败:我试着像这样放置“phpmailer”。需要_一次(phpmailer/class.smtp.php),但它将返回到旧错误:(很明显,它无法连接,可能是端口被阻止了?你检查了谁负责网络了吗?对不起,但是是哪个网络?我如何检查?请包括这两个文件。require_once('class.phpmailer.php');require_once('class.smtp.php');
Irfan,有一个错误,说.require_once(class.phpmailer.php):无法打开流:我已尝试像这样放置“phpmailer”。需要\u一次(phpmailer/class.smtp.php),但它将返回到旧错误。:(出现错误。:(无法发送邮件。邮件错误:smtp connect()失败。您是否从您的帐户中打开了您的设置?源中的使用地址是什么?端口:25不是587我为您编辑了代码..复制并粘贴到您的源..同时刷新您的浏览器并重试..打开设置后,只需重新刷新页面或关闭浏览器并再次打开..感谢您的努力,但SMTP connect()再次失败。出现错误。:(无法发送邮件。邮件程序错误:SMTP connect()失败。您是否从您的帐户中打开了您的设置?源中的使用地址是什么?端口:25不是587我为您编辑了代码..复制并粘贴到您的源..同时刷新您的浏览器并重试..打开设置后,只需重新刷新页面或关闭浏览器并再次打开..感谢您的努力,但SMTP connect()再次失败。