How to config default Return-Path in php mail

Posted In Mail - By Tum. On Tuesday, November 20th, 2012 With 0 Comments

email php
หากเกิดเหตุการณ์ที่ Mail server บางที่ไม่ยอมรับ email จากเราที่ส่งด้วย php script โดยมี error ตามด้านล่าง

(host ezylinux.com[74.xx.xxx.xxx] said: 550-Verification failed for 550-The mail server could not deliver mail to apache@Server1.us.idc. The account or domain may not exist, they may be blacklisted, or missing the proper dns entries. 550 Sender verify failed (in reply to RCPT TO command))


สาเหตุของปัญหานี้เกิดจากเราไม่ได้กำหนดค่า “Return-path” ไปใน mail header ซึ่งระบบ Mail server บางที่จะมีความเข้มงวดเรื่องนี้จึงได้ reject email จากระบบของเรา

สำหรับการแก้ไขปัญหาสามารถทำได้โดยการระบุ “Return-path” ให้กับ Mail header ซึ่งสามารถทำได้ 3 วิธีด้วยกัน คือ

  • Solution 1: mail() function
    ให้ใส่ parameter -f ไปยัง mail function ใน argument ที่ 5 ตามตัวอย่าง
  • Solution 2: php.ini
    แก้ไขไฟล์ php.ini โดยระบุ default “Return-path” ด้วย parameter -f เข้าไปยัง sendmail_path ตามตัวอย่าง
  • Solution 3: Apache vhost
    กำหนดค่า php value ในแต่ละ Virtual Hosts ด้วยการใส่ค่า php_admin_value ตามตัวอย่างด้านล่างเข้าไป

*ในตัวอย่างนี้กำหนดให้ email สำหรับ “Return-path” คือ returnAddress@yourdomain.com

Ref: How to add default Return-path in php mail

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

*