|
 |
|
PHP - ช่วยดู โค้ดให้หน่อยคับ มันผิดพลาดตรงไหน ถึงส่งเมล์ตอบรับไม่ได้อ่ะคับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
#rentdetail
break;
case "1":
$id = $_REQUEST['id'];
$rentid = $_REQUEST['rentid'];
$ac = $_REQUEST['ac'];
$tpid = $_REQUEST['tpid'];
$lnks = "?ctrl=rentday";
switch($ac) {
case "updatepay":
$sql ="update tbl_rentdetail set status=3 where rentid='".$rentid."' ";
$result = mysql_query($sql);
if (!$result) {
echo("เอ็กซิคิวต์คำสั่ง SQL ไม่ได้ " . mysql_error() );
exit();
}
# ฟังก์ชั่น ส่ง EMAIL
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = ',435264091016;';
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to,"MIHAI");
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
$to = $_REQUEST['mail'];
$from = "[email protected]";
$from_name ="เกล็ดดาวรีสอร์ท";
$subject = "รายละเอียดการจองห้องพัก";
$body = "รายการจองห้องพักของคุณเสร็จเรียบร้อยแล้ว";
if (smtpmailer($to, $from, $from_name, $subject, $body)) {
//echo "ส่งแล้ว";
echo"<script>alert('ส่งอีเมล์เรียบร้อยแล้ว');window.location='$lnks';</script>";
}
if (!empty($error)) {
echo $error;
exit();
}
echo"<script>window.location='?ctrl=showrent';</script>";
exit();
break;
}
}
} else {
echo "<script>alert('คุณไม่ใช่ผู้ดูแลระบบ');window.location='index.php?ctrl=mainpages';</script>";
exit();
}
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-09-08 13:42:34 |
By :
นารุโตะ |
View :
724 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
- ขึ้น error อัลไลมั่งครัส
- เวลาใส่ code กรุณาใส่ใน bbcode ด้วยครัส อ่ายยาก + ยาวเกิน แหม่....
|
 |
 |
 |
 |
Date :
2013-09-08 14:19:39 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอ เอา ขึ้น host แร้ว มัน error ตรงที่ ส่งเมล์ตอบรับอ่ะคับ
มันเป็นเพราะสคริป หรือเพราะ Host กันคับ
Code (PHP)
# ฟังก์ชั่น ส่ง EMAIL
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = ',435264091016;';
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to,"MIHAI");
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
$to = $_REQUEST['mail'];
$from = "[email protected]";
$from_name ="เกล็ดดาวรีสอร์ท";
$subject = "รายละเอียดการจองห้องพัก";
$body = "รายการจองห้องพักของคุณเสร็จเรียบร้อยแล้ว";
if (smtpmailer($to, $from, $from_name, $subject, $body)) {
//echo "ส่งแล้ว";
echo"<script>alert('ส่งอีเมล์เรียบร้อยแล้ว');window.location='$lnks';</script>";
}
if (!empty($error)) {
echo $error;
exit();
}
|
 |
 |
 |
 |
Date :
2013-09-08 18:21:20 |
By :
F4 ปลอมตัวมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็แล้วเออเรอร์มันบอกว่าอัลไลเล่าครัส แหม่...
|
 |
 |
 |
 |
Date :
2013-09-08 18:51:41 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แจกฟรี Script ส่งอีเมล์แบบ SMTP / POP ของ PHP ที่สามารถใช้งานได้จริง ๆ
ลองทดสอบ Script ง่าย ๆ ดูครับ
|
 |
 |
 |
 |
Date :
2013-09-09 06:22:19 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

เป็นไปได้มั้ยคับที่ จะเป็นเพราะ Host พอดีใช้ Host ฟรี
|
 |
 |
 |
 |
Date :
2013-09-09 18:08:55 |
By :
F4 ปลอมตัวมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเซ็ต จาก
Code (PHP)
$mail->SMTPDebug = 0;
เป็น
Code (PHP)
$mail->SMTPDebug = 1;
ดูครับ แล้วบอกหน่อยว่ามันบอกอะไรมามั่ง ^^
|
 |
 |
 |
 |
Date :
2013-09-09 18:23:52 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

ขึ้นเเบบเน้คับ
|
 |
 |
 |
 |
Date :
2013-09-09 22:38:42 |
By :
F4 ปลอมตัวมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้ที่ผมใช้
Code (PHP)
<?php
// Variable
$host = 'ssl://smtp.gmail.com:465';
$from = 'Sender email';
$pass = 'Password';
$fromname = 'AdminPKS';
$subject = 'Test SMTP Mailer - noreply';
$to = 'Email to Send';
$message = '<font size="+6">รหัสผ่านใหม่คือ <font color="#FF0000">12345</font></font>';
// Main code
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = $host; // sets GMAIL as the SMTP server
//$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = $from; // GMAIL username
$mail->Password = $pass; // GMAIL password
$mail->From = $from; // "[email protected]";
$mail->FromName = $fromname; // set from Name
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddReplyTo($from, $from);
$mail->AddAddress($to); // to Address
$mail->set('X-Priority', '3'); //Priority 1 = High, 3 = Normal, 5 = low
if(!$mail->Send())
{
echo 'Mailer Error: ' . $mail->ErrorInfo.'<br />';
}
else
{
echo 'Message has been sent<br />';
}
?>
|
 |
 |
 |
 |
Date :
2013-09-09 23:10:42 |
By :
Krungsri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|