วันพฤหัสบดีที่ 23 กุมภาพันธ์ พ.ศ. 2555

Auto-responder บน Postfix กับ Virtual Domain

ตามชื่อเลยครับ Auto-responder หรือบางคนก็เรียกว่า auto reply  ปกติแล้วการทำ auto-reply มันจะง่ายมากถ้าหากเป็นการติดตั้ง postfix แบบ domain เดียว เพราะค่า configure ต่าง ๆ สำหรับแต่ละ user ก็จะเป็นการกำหนดค่าของแต่ละ user ใน home directory นั่นเอง

แต่พอเป็น Virtual Domain/ User เราก็ต้องมาศึกษากันอีกทีว่าทำอย่างไร

พูดถึง Postfix พอเราไปดูก็จะพบว่า การใช้งาน Autoresponse ไม่ได้พูดถึงมานานแล้ว ก็คงเป็นเพราะว่าเดี๋ยวนี้เป็นการติดต่อแบบ realtime คือใช้งานผ่าน มือถือ social network แล้ว

แต่ก็ขอเขียนไว้ที่นี่ถึงวิธีการสักหน่อยเผื่อต้องใช้งาน auto-reply กันจริง ๆ

เริ่มจาก หน้านี้ http://workaround.org/ispmail/etch ก็จะพูดไว้ว่ามีคนทำ add-on ไว้เหมือนกันที่ http://www.remofritzsche.ch/goldfish/  แต่ก็อยากให้ไปอ่านต่อที่ http://eugenesklyar.com/roundcube-autoresponder-goldfish-autoreply-plugin เพื่อติดตั้ง plug-in ของ roundcube เพื่อเปิดให้ user ทำการกำหนดค่าเองได้ด้วย

พอผมมาดูก็ปรากฏว่าต้องมีการแก้ไขบางอย่างอีกนิดหน่อยกว่าจะใช้งานได้

แก้ไขไฟล์ autoresponder.php (ที่ได้จาก http://www.remofritzsche.ch/goldfish/ ตอนนั้นเป็น Version 1.0-STABLE)


/* General */
    $conf['cycle'] = 5 * 60;
   
    /* Logging */
    $conf['log_file_path'] = "/var/log/autoreply";
    $conf['write_log'] = true;
 
   
    # This query has to return the path (`path`) of the corresponding
    # maildir-Mailbox with email-address %m
    $conf['q_mailbox_path'] = "SELECT CONCAT('/home/vmail/', SUBSTRING_INDEX(email,'@',-1), '/', SUBSTRING_INDEX(email,'@',1), '/Maildir/') as `path` FROM virtual_users WHERE `email` = '%m'";
   
    # This query has to return the following fields from the autoresponder table: `from`, `to`, `email`, `message` where `enabled` = 2
    $conf['q_forwardings'] = "SELECT * FROM `autoresponder` WHERE `enabled` = 1 AND `force_enabled` = 1;";
   
    # This query has to activate every autoresponder entry which starts today
    $conf['q_enable_forwarding'] = "UPDATE `autoresponder` SET `enabled` = 1 WHERE `from` >= CURDATE();";
   

ภายหลังจากของใช้งานจาก /usr/bin/php autoresponder.php แล้วก็จะพบว่ามีการส่ง email ออกไปแล้วตามกำหนดค่าของ $conf['cycle'] คือเป็นการกำหนดว่าจะทำการส่ง auto-reply ให้กับ email ที่ส่งเข้ามาหา user คนนี้ไม่เกิน 5 นาที (5x60 วินาทีนั่นเอง)


วันอังคารที่ 14 กุมภาพันธ์ พ.ศ. 2555

ระบบต่อไป อะไรเอ๋ย?

ระบบต่อไป... อะไรเอ๋ย?

ดูเหมือนช่วงนี้วุ่น ๆ กับการติดตั้งเพื่อใช้งานระบบ นี่ก็พึ่งจะได้ระบบ Survey มาใช้งาน ด้วยระยะเวลาอันน้อยนิด

ต่อมาคงเป็นระบบประมาณนี้

http://www.postgis.org/documentation/casestudies/2008-09-rento/





แนวคิดแบบนี้จะติดตามมาอีกเยอะในอนาคต เช่น



  • จากตรงนี้ โรงหนังที่กำลังจะฉายเรื่อง Titanic ณ เวลา 14:00 น. มีที่ไหนบ้าง โดยใช้เวลาเดินทางไม่เกิน 30 นาที
  • ข้าวขาหมู อร่อย ๆ ที่ยังไม่เคยไปกิน และมีเพื่อนอยู่ใกล้ ตรงนั้น (จะได้ชวนกันไป)