 |
ใช้ PHP Mailer เเล้วขึ้น error ดังนี้ค่ะ Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '} |
|
 |
|
|
 |
 |
|
ไม่เห็นโค๊ดก็ไม่รู้จะแก้ยังไงเหมือนกันคับ 
|
 |
 |
 |
 |
Date :
2012-08-15 13:55:48 |
By :
ichiko |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
soce code ค่ะ
Code (PHP)
<?php
/* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */
//This will send an email using auth smtp and output a log array
//logArray - connection,
function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message)
{
//SMTP + SERVER DETAILS
/* * * * CONFIGURATION START * * * */
$smtpServer = "smtp.bangkoksolar.com";
$port = "25";
$timeout = "30";
$username = "[email protected]";
$password = "P@ssw0rd";
$localhost = "smtp.bangkoksolar.com";
$newLine = "\r\n";
/* * * * CONFIGURATION END * * * * */
//Connect to the host on the specified port
$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
$smtpResponse = fgets($smtpConnect, 515);
if(empty($smtpConnect))
{
$output = " <br >Failed to connect: $smtpResponse";
echo $output;
return $output;
}
else
{
echo " <br >Connected: $smtpResponse";
$logArray['connection'] = "Connected: $smtpResponse";
}
//Request Auth Login
fputs($smtpConnect,"AUTH LOGIN" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authrequest'] = "$smtpResponse";
echo " <br >Request Auth Login".$logArr['authrequest'];
//Send username
fputs($smtpConnect, base64_encode($username) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authusername'] = "$smtpResponse";
echo " <br >Send username ".$logArray['authusername'];
//Send password
fputs($smtpConnect, base64_encode($password) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authpassword'] = "$smtpResponse";
echo "<br > Send username ".$logArray['authusername'];
//Say Hello to SMTP
fputs($smtpConnect, "HELO $localhost" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['heloresponse'] = "$smtpResponse";
echo "<br > Say Hello to SMTP ".$logArray['heloresponse'];
//Email From
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
echo "<br > Email From ".$logArray['mailfromresponse'];
//Email To
fputs($smtpConnect, "RCPT TO: $to" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailtoresponse'] = "$smtpResponse";
echo "<br >Email To ".$logArray['mailtoresponse'];
//The Email
fputs($smtpConnect, "DATA" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data1response'] = "$smtpResponse";
echo "<br > The Email ".$logArray['data1response'];
//Construct Headers
$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
$headers .= "To: $nameto <$to>" . $newLine;
$headers .= "From: $namefrom <$from>" . $newLine;
fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data2response'] = "$smtpResponse";
echo "<br > Construct Headers ".$logArray['data2response'];
// Say Bye to SMTP
fputs($smtpConnect,"QUIT" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['quitresponse'] = "$smtpResponse";
echo "<br >\nSay Bye to SMTP ".$logArray['quitresponse'];
//insert var_dump here -- uncomment out the next line for debug info
//var_dump($logArray);
}
?>
<?php
//new function
$to = "[email protected]";
$nameto = "Who To";
$from = "[email protected]";
$namefrom = "siri to";
$subject = "Hello World Again!";
$message = "World, Hello!";
$res=authSendEmail($from, $namefrom, $to, $nameto, $subject, $message);
echo $res;
?>
|
ประวัติการแก้ไข 2012-08-16 14:03:20
 |
 |
 |
 |
Date :
2012-08-15 15:07:37 |
By :
OaLunla |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
class.phpmailer.php ไฟล์นี้ไปเผลอแก้หรือเผลอพิมพ์อะไรเข้าไปหรือเปล่า ลองโหลดมาใหม่ แล้ววางทับไปดู
|
 |
 |
 |
 |
Date :
2012-08-15 15:48:24 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่นะค่ะ ไมได้แก้ไขอะไร ซึ่งในส่วนของ phpmailer ที่ทดลองทำใน Appserv สามารถส่งเมลล์ได้ปกตินะค่ะ แต่พอเอาขึ้น server กลับรันไม่ได้ค่ะ
|
 |
 |
 |
 |
Date :
2012-08-15 16:53:50 |
By :
OaLunla |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้นะ มันฟ้อง syntax error ที่ไฟล์นั้นอะ
|
 |
 |
 |
 |
Date :
2012-08-15 18:42:44 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
error ในไฟล์นั้นครับ ลองโหลดใหม่มาทับเก่า
|
 |
 |
 |
 |
Date :
2012-08-15 23:59:08 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูแล้วไม่น่าจะผิดนะคับ ว่าแต่ไฟล์นี้ใช่หรือเปล่าครับ source code อ่ะคับ
มันมีโค๊ดมากกว่านี้หรือเปล่าคับ
|
 |
 |
 |
 |
Date :
2012-08-16 09:36:37 |
By :
ichiko |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|