เขียน เทสด้วย phpmailer ส่งด้วย function IsSendmail

เจอ error Mailer Error: Could not execute: /usr/sbin/sendmail -t -i -f

เลยลองเขียน ใช้ mail ปกติ ไม่เจอ error แต่ไม่ได้รับ

ลองเขียนด้วย smtp ไปใช้ google app ส่งได้

Host ที่ใช้บริการอยู่แจ้งว่า เขียน script ไม่เป็น มันแก้ง่ายๆ ให้ไปแก้เอาเอง คิดว่าควรจะทำอย่างไรดี lol

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

file ที่ส่งเมล์

Feedback Form

<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
?>
">
To:
From:
Subject:
Message:

<?php
} else {
require_once('class.phpmailer.php');

$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->IsSendmail(); // telling the class to use SendMail transport  
$body = "test";

$mail->SetFrom($_POST["from"], 'First Last');

$address = $_POST["to"];
$mail->AddAddress($address, "John Doe");

$mail->Subject = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);


if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

}
?>

mix5003 Mon, 28/07/2014 - 19:40

ผมว่าถ้า mail() ธรรมดายังไม่เข้า(แบบไม่ใส่ header เพิ่มเลยนะ) ไม่น่าใช่ Code แล้วนะครับ แต่ก็ขึ้นอยู่กับว่าส่งไปไหนด้วย ถ้าส่งไป hotmail มันต้องยืนยัน domain ก่อนหรืออะไรนี่แหละมันถึงจะส่งเข้า ลองใช้ mail ส่งเข้าพวก gmail ดูครับ ถ้าไม่เข้าผมว่าเป็นที่ host นะ

หรือที่เค้าบอกคือหมายถึงให้ใช้ SMTP รึเปล่าหว่า

ปล ใช้ ​Host ที่ไหนอ่ะครับ NetD.... รึเปล่าหว่า

PandaBaka Mon, 28/07/2014 - 21:12

ลอง phpinfo ดูครับว่ามันมีคำสั่ง mail หรือเปล่าแล้วมันเป็น version อะไร
บางทีอาจเจอ host เก่าๆ ใช้ php4 อยู่ก็เป็นไปได้

แต่แนะนำโทรไปจิก hosting ดีที่สุด

Ford AntiTrust Mon, 28/07/2014 - 22:53

host disable function exec/system ไว้หรือเปล่า เหมือนตัว mailer มันสั่งคำสั่งจาก command โดยตรงแทน function พื้นฐาน

เค้าบอกว่า "เปิดให้ใช้" นี่หมายถึงอะไรครับ

เข้าใจว่าเค้าคงบอกคุณว่าเปิดให้ส่งเมลได้ แต่คุณดันไป exec sendmail เอง ซึ่งไม่มีโฮสไหนรองรับอยู่แล้วครับ (ถ้าโฮสไหนรองรับ exec ก็ควรย้ายออกนะ)

ผมว่าอาจจะเป็นแบบที่คูน Ford AntiTrust บอกคือมันอาจจะไปสั่งตรงๆ อันนี้ host อาจจะปิดเพื่อความปลอดภัย

บางทีเค้าอาจจะมี SMTP ของ Host รึเปล่าครับ ต้องส่งผ่าน SMTP ของเค้าอ่ะ อย่างถ้าเปน DirectAdmin จะกดเขาไปดูตรง E-Mail Accounts จะมีเมลให้ใช้เค้าอาจจะให้ใช้อันนั้นรึเผล่า

ถ้ายังไม่ได้อีก ลองให้ Host เขียนตัวอย่างมาให้ดูครับ

ลองเขียน 2 function ครับ ใช้ mail() กับ sendmail

ลองเทสแบบใช้ mail() แล้วส่งเข้าเมล์ของ บริษัท hosting ได้อย่างเดียว ลองเชค mx record แล้วเมล์เขาใช้ google app

แต่ส่งออก free email ไม่ได้ เขาบอกว่า script เราเขียนไม่ดี

ต้องทำไงดี

ถ้าจะใช้ฟังชั่น mail คุณก็ต้องใส่ header ให้ครบครับ หน้าที่คนเขียนโค้ดครับ

ป.ล. รวมถึงใส่ spf record ด้วย อันนี้บางโฮสจะใจดีใส่ให้ แต่ปกติต้องใส่เองครับ

ปรกติตัว dns ใน cp มักจะแก้ไขได้เองจาก cp นะครับ

ถ้าแก้ไขไม่ได้เลย แนะนำหา 3rd party dns hosting ทำงานร่วมกับ hosting จะดีกว่ามากครับ (ผมใช้แยกกันเลย จ่ายเพิ่มนิดหน่อย สบายกว่าใช้ของ hosting แถมเวลาย้ายก็ง่ายและอัพเดทเร็วกว่ามาก)

whmcs ไม่ใช่ hosting control panel นะครับ ปกติจะต้องมี control panel อย่างเช่น directadmin, plesk อยุ่ด้านหลังอีกทีครับ

หรือท่านหมายถึง whm cpanel ผมดู docs มันก็ทำได้นะครับ

อาการส่งเมลออกได้แต่ใน hosting อันนี้เหมือนกับว่าตัว host resolve ตัว mail server เป็นตัวมันเอง ไม่ใช่ google apps มันเลยวิ่งเข้าตัวเอง แต่ถ้าใช้ smtp ภายนอกจะส่งได้ปรกติ อันนี้น่าจะต้องไปแก้ที่ตัว sendmail ของ host แฮะ ผมไม่แน่ใจ เหมือนมันมี config บางตัวที่ต้องไปเอาออกรายตัว ถ้าใช้ mx ภายนอก ถ้าไม่ใช้ของ hosting (ผมก็จำไม่ได้แล้วว่าอะไร)

ทางแก้ไขที่ดีที่สุดที่ผมเคยใช้ถ้าเจอเคสนี้คือใช้ smtp ภายนอกเป็นตัวส่งแทนครับ อย่างที่ผมใช้คือ mailgun.com

ตอนที่ทำกับ Google Apps มีปัญหาการส่งเมลออกตลอด ตอนแรกคิดว่าเป็นที่โฮสครับ พอเลิกใช้ Google Apps มาใช้เมลของโฮสถึงได้รู้ว่ามันง่ายกว่าตอนเซ็ตค่าใน Google Apps เยอะครับ ส่งออกได้ทุกเมลด้วยฟังก์ชั่น mail ธรรมดาโดยคลิกแค่ Checkbox ตรง mx record