|
 |
|
สอบถามเรื่องส่งเมลล์ของเว็บ HostingXXXXXX.com หน่อยครับลองมาเกือบ 2 อาทิตย์แล้ว |
|
 |
|
|
 |
 |
|
คือว่าผมส่งเมล์แล้วมันเป็นแบบนี้

- ตรงส่วน subject จะไม่มี ถ้าผมใช้ $subject .= $subject; แต่ถ้าใช้ $subject .= $subject1; ตรงส่วน $body ก็จะไม่เป็นภาษาไทย
- ถ้าใช้แบบนี้ $subject = "=?UTF-8?B?".base64_encode($subject1)."?="; >> subject ขึ้นปกติแต่ $body ก็ไม่เป็นไทย
- หรือใช้ "'MIME-Version: 1.0' . \r\nContent-type: text/html; charset=utf-8\r\n"; แทรกตรง $from เมลล์ก็จะส่งไม่ผ่าน เมลล์จะส่งผ่านก็ต่อเมื่อรูปแบบถูก ประมาณ [email protected] , [email protected] , [email protected]
- ถ้าแทรมไว้ก่อน $body เมลล์ก็จะเป็นต่างดาวเหมือนเดิม
รบกวนผู้รู้ตอบผมหน่อยนะครับงมมานานมาก เอาวิธี @mail($strTo,$strSubject,$strMessage,$strHeader); ก็ใช้ไม่ได้อ่าครับใช้โฮสของ Hostingdynamo.com ขอบคุณล่วงหน้าครับ
Code (PHP)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?
include('SMTPconfig.php');
include('SMTPClass.php');
$name = $_POST['name'];
$companyName= $_POST['companyName'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$subject1 = $_POST['subject'];
$comment = $_POST['comment'];
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = $admail;
//$subject = "=?UTF-8?B?".base64_encode($subject1)."?=";
$subject = "Content-type: text/html; charset=utf-8\n";
$subject .= $subject;
$from = $email;
$body = "From : ".$name."<br/>Company : ".$companyName."<br/>Mobile phone : ".$tel."<br/>Email : ".$email."<br/><br/>Subject : ".$subject1."<br/>Question/Suggest : ".$comment;
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $from, $body, $subject);
$SMTPChat = $SMTPMail->SendMail();
}
?>
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
class SMTPClient
{
function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $from, $body, $subject)
{
$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;
if ($SmtpPort == "")
{
$this->PortSMTP = 25;
}
else
{
$this->PortSMTP = $SmtpPort;
}
//echo $this->subject."<br/>";
//echo $this->body."<br/>";
//echo $this->from."<br/>";
}//End class
function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser."\r\n");
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass."\r\n");
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, "DATA\r\n");
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT ...
fputs ($SMTPIN, "QUIT\r\n");
fclose($SMTPIN);
//
}
return $talk;
}
}//End function
?>
Tag : PHP

|
ประวัติการแก้ไข 2011-12-09 00:27:54 2011-12-09 00:28:57
|
 |
 |
 |
 |
Date :
2011-12-09 00:18:57 |
By :
voltzuzaa |
View :
972 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาของ phpmailer มาใช้จะง่ายกว่ามั้ยครับ? ส่งได้ทุกแบบทุกภาษาด้วย
|
 |
 |
 |
 |
Date :
2011-12-09 01:15:21 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับผมที่ให้คำปรึกษา พอดีเพิ่งกลับจากต่างจังหวัด เดี๋ยวถ้าได้แล้วยังไงจะมีโพสครับ
|
 |
 |
 |
 |
Date :
2011-12-11 19:49:03 |
By :
voltzuzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ทำตามนี้อ่าครับ ขอบคุณทุกท่านที่ช่วยมาตอบครับขอบคุณครับ
เครดิต http://www.picohosting.com/howto/phpmailer
|
 |
 |
 |
 |
Date :
2011-12-11 23:46:15 |
By :
voltzuzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|