สยามอีโคโฮสต์ดอทคอม

เว็บไซต์นี้ได้รับประกาศนียบัตร ผ่านเกณฑ์การประกวดเว็บไซต์พาณิชย์อิเล็กทรอนิกส์ดีเด่น Best e-Commerce Website Award 2016 จากกรมพัฒนาธุรกิจการค้า
Bangkok booked.net
+28°C
Follower Us
Share This Page
Page Views
  • Visitor Online
     
  •  12 
    เปิดทำการ จันทร์ - เสาร์ เวลา 09:00 - 20:00 น. ขณะนี้เป็นเวลา: เปิดทำการ
    นอกเวลาทำการหรือวันหยุด กรุณาติดต่อผ่านช่องทาง Robot Support หรือ Email: support@siamecohost.com
  • การส่งอีเมล์ด้วย PHPMailer

    การส่งอีเมล์ด้วย PHPMailer

    Update
    23/10/2021 11:40 AM


    1.) สร้างแบบฟอร์ม สำหรับกรอกข้อมูล เพื่อส่งอีเมล์ผ่านหน้าเว็บ ตั้งชื่อไฟล์เป็น form2mail.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>แบบฟอร์มติดต่อสอบถาม</title>
    </head>
    <body>
    <center><br>
    <b>แบบฟอร์มติดต่อสอบถาม<b></br></br>
    <form id="form1" name="form1" method="post" action="sendmail.php">
    <table width="415" border="0" cellspacing="1" cellpadding="1">
    <tr>
    <td colspan="2"> </td>
    </tr>
    <tr>
    <td>ชื่อ-นามสกุลผู้ส่ง</td>
    <td><input name="name" type="text"></td>
    </tr>
    <tr>
    <td>อีเมล์ผู้ส่ง</td>
    <td><input name="email" type="text"></td>
    </tr>
    <tr>
    <td>หัวข้อ</td>
    <td><input name="subject" type="text" id="subject"></td>
    </tr>
    <tr>
    <td valign="top">ข้อความ</td>
    <td><textarea name="details" cols="30" rows="5" wrap="virtual" id="details"></textarea></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><input type="submit" name="Submit" value="Send Mail" /></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    

    ตัวอย่างการแสดงผลหน้า form2mail.html



    2.) สร้าง script php เพื่อรับค่า input จาก formmail.html แล้วส่งข้อมูลไปให้ผู้รับตามที่กำหนด โดยตั้งชื่อไฟล์เป็น sendmail.php

    1. การส่งอีเมล์โดยใช้ SMTP ของโฮสต์ (ไม่แนะนำ เนื่องจากมีการลิมิต และ อีเมลล์มีโอกาสเข้าไปอยู่ Junk mail )

    
    <?
    require("phpmailer/class.phpmailer.php"); // path to the PHPMailer class.
    
    $fm = "you@yourdomain.com"; // *** ต้องใช้อีเมล์ @yourdomain.com เท่านั้น  ***
    $to = "support@yourdomain.com"; // อีเมล์ที่ใช้รับข้อมูลจากแบบฟอร์ม
    $custemail = $_POST['email']; // อีเมล์ของผู้ติดต่อที่กรอกผ่านแบบฟอร์ม
    
    $subj = $_POST['subject'];
    
    /* ------------------------------------------------------------------------------------------------------------- */
    $message.= "ชื่อ-นามสกุล: ".$_POST['name']."\n";
    $message.= "อีเมล์: ".$_POST['email']."\n";
    $message.= "หัวข้อ: ".$_POST['subject']."\n";
    $message.= "รายละเอียด: ".$_POST['details']."\n";
    /* ------------------------------------------------------------------------------------------------------------- */
    
    /* หากต้องการรับข้อมูลจาก Form แบบไม่ระบุชื่อตัวแปร สามารถรับข้อมูลได้ไม่จำกัด ให้ลบบรรทัด 11-14 แล้วใช้ 19-22 แทน 
    	
    foreach ($_POST as $key => $value) {
     //echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."
    "; $message.= "Field ".htmlspecialchars($key)." = ".htmlspecialchars($value)."\n"; } */ $mesg = $message; $mail = new PHPMailer(); $mail->CharSet = "utf-8"; /* ------------------------------------------------------------------------------------------------------------- */ /* ตั้งค่าการส่งอีเมล์ โดยใช้ SMTP ของ โฮสต์ */ $mail->IsSMTP(); $mail->Mailer = "smtp"; $mail->SMTPAuth = true; //$mail->SMTPSecure = 'ssl'; // บรรทัดนี้ ให้ Uncomment ไว้ เพราะ Mail Server ของโฮสต์ ไม่รองรับ SSL. $mail->Host = "mail.yourdomain.com"; //ใส่ SMTP Mail Server ของท่าน $mail->Port = "25"; // หรือ "587" หมายเลข Port สำหรับส่งอีเมล์ $mail->Username = "yourname@yourdomain.com"; //ใส่ Email Username ของท่าน $mail->Password = "password"; //ใส่ Password ของอีเมล์ (รหัสผ่านของอีเมล์ที่ท่านตั้งไว้) /* ------------------------------------------------------------------------------------------------------------- */ $mail->From = $fm; $mail->AddAddress($to); $mail->AddReplyTo($custemail); $mail->Subject = $subj; $mail->Body = $mesg; $mail->WordWrap = 50; // if(!$mail->Send()) { echo 'Message was not sent.'; echo 'ยังไม่สามารถส่งเมลล์ได้ในขณะนี้ ' . $mail->ErrorInfo; exit; } else { echo 'ส่งเมลล์สำเร็จ'; } ?>

    2. การส่งอีเมล์โดยใช้ SMTP ของ Gmail / G-Suite (WorkSpace) - Update 23/10/2021

    โปรดทราบ email@gmail.com ส่งฟรีได้ 500 ฉบับ/วัน, G-Suite/WorkSpace email@yourdomain.com ส่งได้ 2,000 ฉบับ/วัน

    
    <?
    require("phpmailer/class.phpmailer.php"); // path to the PHPMailer class.
    
    $fm = "you@gmail.com"; // *** ต้องใช้อีเมล์ @gmail.com เท่านั้น ***
    $to = "support@yourdomain.com"; // อีเมล์ที่ใช้รับข้อมูลจากแบบฟอร์ม
    $custemail = $_POST['email']; // อีเมล์ของผู้ติดต่อที่กรอกผ่านแบบฟอร์ม
    
    $subj = $_POST['subject'];
    
    /* ------------------------------------------------------------------------------------------------------------- */
    $message.= "ชื่อ-นามสกุล: ".$_POST['name']."\n";
    $message.= "อีเมล์: ".$_POST['email']."\n";
    $message.= "หัวข้อ: ".$_POST['subject']."\n";
    $message.= "รายละเอียด: ".$_POST['details']."\n";
    /* ------------------------------------------------------------------------------------------------------------- */
    
    /* หากต้องการรับข้อมูลจาก Form แบบไม่ระบุชื่อตัวแปร สามารถรับข้อมูลได้ไม่จำกัด ให้ลบบรรทัด 11-14 แล้วใช้ 19-22 แทน
    	
    foreach ($_POST as $key => $value) {
     //echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."
    "; $message.= "Field ".htmlspecialchars($key)." = ".htmlspecialchars($value)."\n"; } */ $mesg = $message; $mail = new PHPMailer(); $mail->CharSet = "utf-8"; /* ------------------------------------------------------------------------------------------------------------- */ /* ตั้งค่าการส่งอีเมล์ โดยใช้ SMTP ของ Gmail */ $mail->IsSMTP(); $mail->Mailer = "smtp"; $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "you@gmail.com"; // Gmail username หรือหากท่านใช้ G-suite / WorkSpace ให้ใช้อีเมล์ @you@yourdomain แทน $mail->Password = "your password"; // Gmail password /* ------------------------------------------------------------------------------------------------------------- */ $mail->From = $fm; $mail->AddAddress($to); $mail->AddReplyTo($custemail); $mail->Subject = $subj; $mail->Body = $mesg; $mail->WordWrap = 50; // if(!$mail->Send()) { echo 'Message was not sent.'; echo 'ยังไม่สามารถส่งเมลล์ได้ในขณะนี้ ' . $mail->ErrorInfo; exit; } else { echo 'ส่งเมลล์สำเร็จ'; } ?>

    3.) เปลี่ยนอีเมล์ผู้รับ จาก contactus@yourdomain.com เป็น ที่อยู่อีเมล์ของท่าน จากนั้น Upload ทั้ง 2 ไฟล์ ขึ้นไปไว้บน Server

    4) ทดสอบการใช้งานโดยเปิดหน้า http://www.yourdomain.com/form2mail.html กรอกข้อมูลให้ครบทุกช่อง แล้วคลิกปุ่ม "Send Mail"

    *** คำแนะนำเพิ่มเติม *** สำหรับผู้ใช้ SMTP ของ Gmail หากพบ Mailer Error: SMTP connect() failed. ให้ทำตามขั้นตอนดังนี้ - Update 23/10/2021 ***

    1. เปิดการอนุญาตให้ใช้ smtp google
    http://www.google.com/accounts/DisplayUnlockCaptcha

    2. ปิดการยืนยันแบบ 2 ขั้นตอน
    https://support.google.com/accounts/answer/1064203?hl=th

    3. เปิด อนุญาตให้แอปที่มีความปลอดภัยน้อยเข้าถึงบัญชีของคุณ
    https://myaccount.google.com/lesssecureapps

    หากไม่พบ Error แสดงว่าแสดงว่า Script สามารถใช้งานได้ถูกต้องแล้ว

    ตัวอย่างการแสดงผลหน้า sendmail.php


    5) เข้าไปเช็ค inbox ของอีเมล์ผู้รับ ว่าได้รับอีเมล์หรือไม่ อย่าลืมตรวจสอบใน Junk box หรือ ถังขยะด้วย

    คลิกเพื่อ Download PHPMailer (เฉพาะไฟล์ที่จำเป็นต้องใช้งาน พร้อมตัวอย่าง Script) --> PHPMailer (Update: 14/3/2559)
    หรือ Save เก็บไว้ใน Google Drive ของคุณ   


    แตกไฟล์ออก แล้ว Upload ขึ้นไปไว้บน Server ใน Folder เดียวกันกับ Script ที่ใช้ส่งอีเมล์


    หมายเหตุ

    การส่งอีเมล์ผ่าน SMTP บน Host ของ Siamecohost.Com ตรงอีเมล์ผู้ส่ง (From/$fm) ต้องใช้อีเมล์ @yourdomain.com เท่านั้น เนื่องจาก Mail Server มีระบบป้องการ SPAM หากท่านใช้อีเมล์อื่นในการรับ เช่น xxx@hotmail.com, yyy@yahoo.com จะพบกับ Error แบบนี้

    PHP Warning: mail(): SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server. in C:\Inetpub\vhosts\yourdomainname.com\httpdocs\sendmail.php on line 7



    ไม่สงวนสิทธิ์ในการนำไปเผยแพร่แต่ต้องแสดงแหล่งที่มา



    Thai e-Commerce Association
    SME Registered
    TrustedSite
    Google Safe Browsing
    DMCA.com Protection Status DMCA compliant image






    Site Map
    Main Menu

    หน้าแรก
    เกี่ยวกับเรา
    คำนิยมจากลูกค้าที่ใช้บริการ
    ดูคำอธิบายบริการแต่ละประเภท
    สาธิตขั้นตอนสมัครใช้บริการ
    ตัวช่วยในการเลือกสินค้า/บริการ
    ขอใบเสนอราคา

    วิธีชำระค่าบริการ
    แจ้งยืนยันการโอนเงิน
    ดาวน์โหลดใบเสร็จรับเงิน
    ประวัติสั่งซื้อ/วันครบกำหนดชำระ

    ข้อตกลงการใช้บริการ
    นโยบายความเป็นส่วนตัว
    การรับประกันความพึงพอใจ
    หลักฐานการจดทะเบียนพาณิชย์
    FAQ รวมคำถามที่พบบ่อย
     ติดต่อสอบถาม

    Siamecohost's Blog
    Product & Service

    Windows Hosting Starter
    Windows Hosting MaxValue Basic
    Windows Hosting MaxValue Plus
    Windows Cloud Hosting (Malaysia)

    Linux Hosting Starter
    Linux Hosting Max Value
    WordPress Cloud Hosting (SG)
    Linux Cloud Hosting (Malaysia)

    Business Email Economy
    Business Email Standard
    Private Email Hosting
    Business Email Premium
    Cloud Email Standard (US)
    Cloud Email Enterprise (US)
    SpamExperts Spam Filtering

    VPS Windows SSD (Malaysia)
    VPS Linux SSD (Malaysia)
    Cloud Server Windows (Thailand) Cloud Server Linux (Thailand)

    Dedicated Server (Thailand)
    Dedicated Server (Malaysia)

    Co-Location (Thailand)
    Domain Name Service

    รายละเอียด/ราคา/จด/ต่ออายุ/โอนย้าย
    เช็คชื่อโดเมน ภาษาอังกฤษ
    เช็คชื่อโดเมน ภาษาไทย
    เช็คชื่อโดเมนทีละหลายชื่อ
    ดูวันที่โดเมนเนมหมดอายุ
    ตรวจสอบชื่อผู้ให้บริการโดเมนเนม
    ตรวจสอบอายุโดเมนเนม
    ดูข้อมูลโดเมน Whois
    คำอธิบายสถานะโดเมน
    วงจรชีวิตโดเมนเนม
    ขั้นตอนการโอนย้ายโดเมน
    ขั้นตอนการโอนย้ายเว็บไซต์
    วิธีแก้ไขข้อมูลโดเมนเนม
    การยืนยันความเป็นเจ้าของโดเมน
    แก้ปัญหาโดเมนถูกระงับการใช้งาน

    Misc. Service

    SSL Certificate
    Email Certificate (S/MIME)
    Document Signing Certificate
    TrustedSite Certifications
    cWatch Website Security
    Sitelock Website Security
    CodeGuard Cloud Backup
    SMEShop Package (e-Commerce)
    Support Center

    ศูนย์ช่วยเหลือและบริการ
    คู่มือการใช้งาน Email เบื้องต้น
    คู่มือการใช้งาน Windows+Plesk
    คู่มือการใช้งาน Linux+DirectAdmin
    คู่มือการใช้งาน Private Cloud Hosting
     แจ้งปัญหาการใช้งาน

    Misc & Free Service

    แหล่งรวมความรู้เพื่อคนทำเว็บ
    ฟรี Widgets ตกแต่งหน้าเว็บ
    Free Counter สถิติผู้เข้าชมเว็บไซต์
    SSL Certificate Tools
    ตรวจสอบความเร็วอินเทอร์เน็ต
    Network Tools (เช็คระบบเน็ตเวิร์ค)
    Email Tools (ตรวจสอบปัญหาอีเมล์)
    ตรวจสอบสถานะของ Server
    ตาราง Backup ข้อมูลรายสัปดาห์
    ดาวน์โหลด ฟรี! SMEShop Script
    ฟรี บริการย่อลิงค์ให้สั้นลง
    ฟรี ระบบแบบฟอร์มออนไลน์
    ส่งไฟล์ขนาดใหญ่ผ่านอีเมล์
    Dropbox ฟรีพื้นที่เก็บไฟล์บนคลาวด์
    บันทึก นัดหมาย การประชุม
    บริการ Payment Gateway

  • Affiliates Partner Program

    Follow Us เว็บไซต์ของฉันอยู่ Server ไหน Free Auto Backlink For SEO

    This website made with Best view with modern web browser. Best View A design css menu by booNavigation jQuery plugin