เนื่องจาก Hotmail มีนโยบายไม่รับเมล์จาก Server ส่วนใหญ่ในไทย จึงจำเป็นต้องหาวิธีส่งเมล์แบบอื่น วิธีนิยมที่สุดคือเปลี่ยนไปใช้ Mail Server ที่สามารถส่งเข้า Hotmail ได้ ในที่นี้จะใช้ Gmail ใน Google Apps

ขั้นตอนย่อๆ

  1. แก้ email.yml
  2. ลง TLS module
    • แก้บั๊ก TLS module – -”
  3. restart apache

ขั้นตอนแบบละเอียด

  1. แก้ไฟล์ config/email.yml ในโฟลเดอร์ Redmine
  2. production:
      delivery_method: :smtp
      smtp_settings:
        address: smtp.gmail.com
        tls: true
        port: 587
        domain: project.in.th
        authentication: :login
        user_name: redmine@project.in.th
        password: myred

    เนื่องจาก Gmail มันต้องส่งข้อมูลแบบเข้ารหัส เลยต้องเพิ่ม tls: true เข้าไปด้วย แต่ยังใช้

  3. ติดตั้ง TLS module โดยไปที่โฟลเดอร์ของ Redmine แล้วสั่ง
  4. ruby script/plugin install http://svn.douglasfshearer.com/rails/plugins/action_mailer_optional_tls

    ยัง! ยังใช้ไม่ได้ โมดูลนี้มันมีบั๊ก ต้องไปแก้ไฟล์ vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb ก่อน

      def do_tls_start(helodomain, user, secret, authtype)
        raise IOError, 'SMTP session already started' if @started
        check_auth_args user, secret, authtype if user or secret

    แก้จากข้างบนเป็น (ลบ authtype ออก)

      def do_tls_start(helodomain, user, secret, authtype)
        raise IOError, 'SMTP session already started' if @started
        check_auth_args user, secret if user or secret
  5. Restart Apache
  6. /etc/init.d/apache2 restart

ทดลองส่งเมล์ได้โดยเข้า Redmine > Administration > Settings > Email notifications แล้วกด Send a test email ด้านล่าง ถ้าทุกอย่างถูกต้องก็จะมีเมล์ส่งมา

Redmine Email Admin

ลองเช็คดู header ของเมล์ที่ส่ง ควรจะมี mailed-by: mail-gx0-f26.google.com อาจแตกต่างกันบ้างเล็กน้อยแล้วแต่โดเมน แต่ต้องลงท้ายด้วย Google เท่านี้ก็ไม่มีปัญหาการส่งเมล์เข้า Hotmail แล้ว ;)

ขอบคุณ: http://www.hiddentao.com/archives/2008/12/06/redmine-svn-mysql-5-lighttpd-15/