PHPMailer问题 [英] PHPMailer problem
本文介绍了PHPMailer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
if(!empty($ _ FILES) ){
$ tempFile = $ _FILES ['Filedata'] ['tmp_name'];
$ targetPath = $ _SERVER ['DOCUMENT_ROOT']。 $ _REQUEST ['folder']。 /;
$ targetFile = str_replace('//','/',$ targetPath)。 $ _FILES [ Filedata上] [名];
// $ fileTypes = str_replace('*。','',$ _ REQUEST ['fileext']);
// $ fileTypes = str_replace(';','|',$ fileTypes);
// $ typesArray = split('\ |',$ fileTypes);
// $ fileParts = pathinfo($ _ FILES ['Filedata'] ['name']);
// if(in_array($ fileParts ['extension'],$ typesArray)){
//如果要使目录不存在,请取消注释以下行
// mkdir(str_replace('//','/',$ targetPath),0755,true);
move_uploaded_file($ tempFile,$ targetFile);
echo1;
//发送确认电子邮件
require_once('_ mailClasses / class.phpmailer.php');
include(class.smtp.php); //可选,如果尚未加载,则从class.phpmailer.php中调用
$ mail = new PHPMailer();
$ body ='有一个新的在线订单。请检查你的订单文件夹。
// $ body = eregi_replace([\],'',$ body);
$ mail-> IsSMTP(); //告诉班级使用SMTP
$ mail-> Host =mail.splashoflondon.com; // SMTP server
$ mail-> SMTPDebug = 2; //启用SMTP调试信息(用于测试)
// 1 =错误和消息
// 2 =仅消息
$ mail-> SMTPAuth = true; //启用SMTP身份验证
$ mail-> Host =mail.splashoflondon.com; //设置SMTP服务器
$ mail-> Port = 26; //设置GMAIL服务器的SMTP端口
$ mail->用户名=adolphus@splashoflondon.com; // SMTP帐户用户名
$ mail-> Password =correctpassword; // SMTP帐户密码
$ mail-> SetFrom('adolphus@splashoflondon.com',Splash of London);
$ mail-> AddReplyTo(ali@xgreen.co.uk,First Last);
$ mail-> Subject =PHPMailer通过smtp测试主题,基本认证;
$ mail-> AltBody =要查看消息,请使用HTML兼容的电子邮件查看器! //可选,注释和测试
$ mail-> MsgHTML($ body);
$ address =ali@xgreen.co.uk;
$ mail-> AddAddress($ address,John Doe);
$ mail-> Send();
}
?>
解决方案
高度建议您在这里查看基本的调试技巧:
http://www.ibm.com/developerworks/library/os-debug/
这是一个很好的阅读,你会看到你的技能作为一个疑难解答跳10倍。
I am new to php. Trying to send confirmation about user upload. I am trying to use PHP Mailer for this. And have the following code but it doesn't work. Any help would be appreciated.
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// $fileTypes = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// $fileParts = pathinfo($_FILES['Filedata']['name']);
// if (in_array($fileParts['extension'],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
move_uploaded_file($tempFile,$targetFile);
echo "1";
//Send confirmation email
require_once('_mailClasses/class.phpmailer.php');
include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = 'There is a new online order. Please check your order folder.';
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.splashoflondon.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.splashoflondon.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "adolphus@splashoflondon.com"; // SMTP account username
$mail->Password = "correctpassword"; // SMTP account password
$mail->SetFrom('adolphus@splashoflondon.com', 'Splash of London');
$mail->AddReplyTo("ali@xgreen.co.uk","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "ali@xgreen.co.uk";
$mail->AddAddress($address, "John Doe");
$mail->Send();
}
?>
解决方案
As you are new to PHP, I highly recommend you check out basic debugging techniques here:
http://www.ibm.com/developerworks/library/os-debug/
It's a good read and you'll see your skills as a troubleshooter jump 10-fold.
这篇关于PHPMailer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文