ส่งเมลแนบไฟล์ ส่งไม่ได้ค่ะ โค้ดมาจากในเว็บนี้แหละ >_<
<!--Send Mail-->
<?php
//echo "<pre>"; print_r($_POST);
//echo "<pre>"; print_r($_GET);
if($_GET['act']=="send"){
//echo "<pre>"; $_POST['file_pdf'];
//echo "----------";
//echo "<pre>"; print_r($_POST);
//echo "----------";
//echo "<pre>"; print_r($_FILES); exit;
//echo "----------";
$arrDatapdf = array();
if(isset($_FILES)){
foreach($_FILES as $key => $val){
if( @ereg("^file", $key)){
if( $val[name] ){
$arrDatapdf[$key] = $objMaster->uploadFiles("file", "../file",$key,"file_","",$_FILES,"");
if($key=="file_pdf"){$chk_File_pdf = $arrDatapdf[$key];}
$chk_File_pdf1 = $arrDatapdf[$key];
}
}
}
}
// echo "<meta http-equiv='refresh' content='0; URL=?name=job&file=regisfrom'>";
// echo "<pre>"; print_r($_FILES);
// exit;
?>
<?php
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('../PHPMailer/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = "" ;
$body ="<table align='' border='1' cellspacing=0 cellpadding=5 width='100%' style='border-collapse: collapse;'>";
$body .="<tr>";
$body .="<td valign=top align='center'>";
$body .="<table align='center' border='0' cellspacing='0' cellpadding='10' width='100%'>";
$body .="<tr>";
$body .="<td>";
$body .="</td>";
$body .="</tr>";
$body .="<tr>";
$body .="<td width=150>";
$body .="ชื่อ :";
$body .="</td>";
$body .="<td>";
$body .="".$_POST[name]."";
$body .="</td>";
$body .="</tr>";
$body .="<tr>";
$body .="<td width=150>";
$body .="เบอร์มือถือ :";
$body .="</td>";
$body .="<td>";
$body .="".$_POST[num1]."-".$_POST[num2]."";
$body .="</td>";
$body .="</tr>";
$body .="<tr>";
$body .="<td>";
$body .="E-mail :";
$body .="</td>";
$body .="<td>";
$body .="".$_POST[email]."";
$body .="</td>";
$body .="</tr>";
$body .="<tr>";
$body .="<td>";
$body .="</table>";
$body .="</td>";
$body .="</tr>";
$body .="</table>";
$mail->IsSMTP(); // telling the class to use SMTP<a href="regisfrom.php">regisfrom.php</a>
$mail->Host = "smtp.gmail.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 = 'ssl://smtp.gmail.com:465'; // sets the SMTP server
//$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected] "; // SMTP account username
$mail->Password = "nut29923s"; // SMTP account password
$mail->SetFrom("[email protected] ", "");
$mail->AddReplyTo("".$_POST[email]."","".$_POST[name]."");
$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 = "[email protected] ";
$mail->AddAddress($address, ".$_POST[name].");
if($_FILES){
foreach($_FILES as $key=> $valfile){
echo $valfile['name'];
}
}
$mail->AddAttachment("file/".$valfile['name'].""); // attachment
$mail->AddAttachment("PHPMailer/examples/images/phpmailer_mini.gif"); // attachment
//exit;
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
?>
<!--End Send Mail-->
<div class="body" >
<div class="body_joblist" align="center">
<table style="width:760px;">
<tr>
<td style="width:82px">
<img src="images/joblist/logo_joblist.png" border="0px" />
</td>
<td><h1>Submit resume Form</h1></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<div class="clear"></div>
<div style="margin:0 auto; width:980px;" id="div-car" class="what">
<form METHOD="POST" name="credit" ACTION="?name=job&file=regisfrom&act=send" enctype="multipart/form-data">
<table border="0px" class="credit" cellpadding="2px" cellspacing="15px;" >
<tr>
<td align="right">ชื่อ</td>
<td><input name="name" class="required" style="width:200px; height:20px; border: 1px solid #D6D6D6; " type="text" ></td>
<td valign="middle"><font style="color:#F00; font-size:16px;">*</font></td>
</tr>
<tr>
<td align="right">เบอร์มือถือ</td>
<td >
<input name="num1" type="text" class="required number" style="width:45px; height:20px; border: 1px solid #D6D6D6;">-
<input name="num2" type="text" class="required number" style="width:146px; height:20px; border: 1px solid #D6D6D6;">
</td>
<td valign="middle"><font style="color:#F00; font-size:16px;">*</font></td>
</tr>
<tr>
<td align="right">E-mail</td>
<td><input name="email" class="required email" style="width:200px; height:20px; border: 1px solid #D6D6D6;" type="text"></td>
<td valign="middle"><font style="color:#F00; font-size:16px;">*</font></td>
</tr>
<tr>
<tr>
<td align="right">แนบไฟล์ Resume</td>
<td><input type="file" name="file_pdf" <?php echo ( !@$arrRes2['file_pdf'] ? "":"DISABLED");?> /></td>
<td valign="middle"><font style="color:#F00; font-size:16px;">*</font></td>
</tr>
<tr>
<td colspan="3" align="right"><input type="submit" name="submit" value="Send" />
</td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
</div>
</div>
อยากทราบว่าทำไมไม่มีเมลส่งไปเลย ไม่รู้ว่าทำยังไง ขอคำตอบหน่อยค่ะ
ขอบคุรมากค่ะTag : PHP
Date :
2010-11-15 10:59:40
By :
ichibi
View :
1309
Reply :
1
ลองเขียนแบบง่าย ๆ ก่อนครับ ว่าสามารถส่งออกไปได้หรือไม่ ถ้าส่งออกได้ แสดงว่า code ตอนนี้น่าจะมีตรงไหนผิดครับ
Date :
2010-11-15 11:13:00
By :
webmaster
Load balance : Server 03