|
|
ausfish
发表于 2009-1-11 19:35:22
|
显示全部楼层
版主帮我看看这段代码哪里设置错误- <?php
- require("../inc/global.php");
- $upload_folder="../".$upload_folder;
- //导入类文件
- require("../inc/class.phpmailer.php");
- $upfile=$_FILES["files"];
- $tmp_file=array();
- $rel_file=array();
- $allowType = array('gif', 'jpg', 'png');
- for($i=0;$i<sizeof($upfile["name"]);$i++){
- $tmp_name=$upfile['name'][$i];
- $ext = explode(".", $tmp_name);
- $ext = $ext[count($ext) - 1];
- srand ((double) microtime() * 1000000);
- $rnd = rand(1,99);
- $pic_name = date('ymdhis') + $rnd;
- $pic_name = $pic_name.".".$ext;
- if(move_uploaded_file($upfile['tmp_name'][$i],$upload_folder.$pic_name)){
- array_push($tmp_file,$tmp_name);
- array_push($rel_file,$pic_name);
- }
- }
- mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("数据库连接失败");
- mysql_query("set names 'gbk'");
- session_start();
- $secruity=$_POST["secruity"];
- if(strtoupper($secruity)!=strtoupper($_SESSION["code"])){
- echo "<script>alert('secruity error!');self.close();</script>";
- exit;
- }
- $result=mysql_db_query($dbname,"select * from company limit 1");
- $obj=mysql_fetch_object($result);
- $site_name=$obj->site_name;
- $manage=$obj->manage;
- $email=$obj->email;
- $url=$obj->url;
- $title=$_POST["mailSubject"];
- $content=$_POST["mailbody"];
- $post_name=$_POST["FromName"];
- $post_company=$_POST["companyname"];
- $post_tel=$_POST["telphone"];
- $post_fax=$_POST["fax"];
- $post_ip=strFunIP();
- $post_mail=$_POST["frommail"];
- $post_country=$_POST["countryCode"];
- //声明类
- $mail = new PHPMailer();
- $mail->CharSet = "utf-8"; // 设置字符集编码
- $mail->Encoding = "base64";//设置文本编码方式
-
- // 设置使用 SMTP
- $mail->IsSMTP();
-
- // 指定的 SMTP 服务器地址
- $mail->Host = "smtp.secureserver.net";
-
- // 设置为安全验证方式
- $mail->SMTPAuth = true;
-
- // SMTP 发邮件人的用户名,注意只填@前面的字符!!!
- $mail->Username = "inquire@info.com";
-
- // SMTP 密码
- $mail->Password = "1234567";
- $mail->From = $email;
- $mail->FromName = $post_name;
- $mail->AddAddress($email,$manage);
-
- //AddAddress函数格式为("收件地址","收件人")
- //$mail->AddAddress("terryxiahui@yahoo.com.cn","dalilng");
- //$mail->AddAddress("xiahui@kaible.com","daling"); // 可选
-
- //可以回复的地址
- $mail->AddReplyTo($post_mail, $post_name);
-
-
- // 50字折行
- $mail->WordWrap = 50;
-
- // 加附件
- //$mail->AddAttachment("/var/tmp/file.tar.gz");
-
- // 附件,也可选加命名附件
- $f=count($tmp_file);
- if($f>0){
- for($i=0;$i<$f;$i++){
- $mail->AddAttachment(realpath($upload_folder.$rel_file[$i]), $tmp_file[$i]);
- }
- }
- // 设置邮件格式为 HTML
- $mail->IsHTML(true);
-
- // 标题
- $mail->Subject = "Oem Inquiry:$title";
-
- // 内容
- $mail_body = "
- <table width=700 border=0 cellpadding=0 cellspacing=0 style='font-family: Arial, Helvetica, sans-serif'>
- <tr>
- <td height='16' colspan=2 bgcolor=#FF0000><h3><font color=#FFFFFF style='font-size: 16px;'>OEM INQUIRE:</font></h3></td>
- </tr>
- <tr style='font-size:12px;'>
- <td colspan=2>Dear $manage</td>
- </tr>
- <tr>
- <td colspan=2>This buyer saw your product on $site_name online and would like to get an Oem Inquiry.</td>
- </tr>
- <tr>
- <td colspan=2 bgcolor=#999999 style='font-size:14px;'><strong>Buyer's message:</strong></td>
- </tr>
- <tr>
- <td colspan=2 style='font-size: 12px;'>$content</td>
- </tr>
- <tr>
- <td colspan=2 bgcolor=#999999 style='font-size:14px;'><strong>Buyer Details:</strong></td>
- </tr >
- <tr bgcolor='#D4D4D4'>
- <td >Name:</td>
- <td>$post_name</td>
- </tr>
- <tr>
- <td>Company Name:</td>
- <td>$post_company</td>
- </tr>
- <tr bgcolor='#D4D4D4'>
- <td>Tel:</td>
- <td>$post_tel</td>
- </tr>
- <tr>
- <td width=92>Fax:</td>
- <td width=235>$post_fax</td>
- </tr>
- <tr bgcolor='#D4D4D4'>
- <td>Business Email:</td>
- <td>$post_mail</td>
- </tr>
- <tr>
- <td>Country:</td>
- <td>$post_country</td>
- </tr>
- <tr bgcolor='#D4D4D4'>
- <td colspan=2>This inquiry was sent from $post_ip</td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- </tr>
- </table>
- <hr align='left' width='700' border='1'/>";
- $mail_body.="This inquiry was sent from:$post_ip
- ";
- $mail_body.="If you have any questions regarding the products,simply contact us at $email our MSN is bensontin@hotmail.com
- Enquiry Received at:$url
- Inquiry Sent:".date($datetxt,time());
-
- $mail->Body = $mail_body;
-
- // 附加内容
- //$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
-
- //$mail->Send()为邮件发送函数,不成功时执行if内容
- $flag=false;
- for($i=0;$i<3;$i++){
- if(!$mail->Send())
- {
- echo "($i)Mailer Error: " . $mail->ErrorInfo . "
- ";
- }else{
- $flag=true;
- break;
- }
- }
- if($flag){
- echo "Message has been sent";
- }else{
- echo "Message have not been sent!";
- }
- for($i=0;$i<$f;$i++){
- if(is_file($upload_folder.$rel_file[$i])){ unlink($upload_folder.$rel_file[$i]); }
- }
- ?>
复制代码 |
|