后端开发|php教程
nbsp,mail,SMTP,gt,SBT
后端开发-php教程
SMTP Error: Could not connect to SMTP host.
我用网页运行时正常,能发送,用命令运行php文件时报错,主要代码经检查无误,如下
有网站源码如何建站,vscode配置路由,ubuntu nlopt,yum升级tomcat,sqlite 最小值,js插件添加标签,怎么学web前端开发框架,爬虫免费写代码软件,html使用php,南京seo代运营,免费购物网站,框架网页 标题,简单图书馆网页模板lzw
function sendmail($setEmail, $setName, $body, $subject) {
require_once("PHPMail/phpmailer.php");
$mail = new PHPMailer ( true ); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP (); // telling the class to use SMTP
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = SBT_SSL; // sets the prefix to the servier
$mail->Host = SBT_SMTP_HOST; // sets GMAIL as the SMTP server
$mail->Port = SBT_SMTP_PORT; // set the SMTP port for the GMAIL server
$mail->Username = SBT_SMTP_USER; // GMAIL username
$mail->Password = SBT_SMTP_PASS; // GMAIL password
$mail->AddReplyTo ( SBT_MAIL_FROM, SBT_MAIL_FROM_NAME );
$mail->AddAddress ( $setEmail, $setName );
$mail->SetFrom (SBT_SMTP_USER,SBT_SMTP_USER); //sender name
$mail->Subject = $subject;
$mail->MsgHTML ( $body );
if (! $mail->Send ()) {//(这边没报错)
echo "Message could not be sent.
";
echo "Mailer Error: " . $mail->ErrorInfo;
exit ();
}
} catch ( phpmailerException $e ) {
echo $e->errorMessage (); //Pretty error messages from PHPMailer(就是这边输出错误的)
} catch ( Exception $e ) {
echo $e->getMessage (); //Boring error messages from anything else!
}
}
问下是什么原因,目的是为了可以用linux计划任务来执行该PHP文件
php文章系统源码,vscode和unity,ubuntu改进,tomcat解包乱码,sqlite qt数据库,dz适配小云的插件,个人网站用什么前端js框架,多来源小说爬虫下载框架,php 5.5编译安装,怎么设置seo网页,企业网站源码wap,html网页样式代码下载,bootstrap 自适应模板lzw
——解决方案——————–
错误代码呢?
——解决方案——————–
php –ini 一下,看使用的ini是否和作为apache模块运行的php一致.
——解决方案——————–
不可能,$mail->IsSMTP ();这个表明你已经设置了smtp发送了.
你现在的主要问题是找找看为什么socket连接不了smtp服务器.
防火墙也有可能.
——解决方案——————–
wamp环境,应该是共用一份ini文件的.想再一次确定的话,php网页输出phpinfo(),看使用的ini文件,是否和这个一致.
命令:telnet 465 ,确定能连接成功?
——解决方案——————–
检查一下防火墙,另外再检查一下发送图片附件的代码
——解决方案——————–
telnet都不行,肯定是你防火墙禁止了访问
k线源码,VScode语言解释器崩溃,ubuntu的美化,改变tomcat的jdk,手机爬虫系统,php传参加密,广州seo服务优化哪家好,网站广告管理系统asp,免费的wordpress企业模板lzw