Tuesday, January 18, 2011

Roundcube auto-reply plugin: Vacation

Evnironment:
OS: FreeBSD 8.1-RELEASE-p1
roundcube: 0.4.2
vacation: 1.9.9
apache: 1.3.42
php: 5.3.3_2
  1. 前提: roundcube已正常運作。也就是apache, php等基本配件已經處理好了。
  2. 下載Vacation plugin,並解壓縮至/roundcube/plugins/內
    (/usr/local/www/roundcube/plugins/)
  3. 先讀過README與INSTALL兩個檔案,並決定要用哪種driver讓auto-reply的功能運作(這邊會以SSHFTP為例)。
  4. 啟用plugin: 修改/usr/local/www/roundcube/config/main.inc.php檔
    找到$rcmail_config['plugins'] 這行,並加入'vacation'

    // List of active plugins (in plugins/ directory)
    $rcmail_config['plugins'] = array('other_plugins','vacation');

  5. 修改/vacation/config.ini檔,指定driver

    [default]
    driver = "sshftp"
    subject = "Default subject"
    body = "default.txt"
    server = host_name

  6. 修改/vacation/config.ini檔的擁有者 與 執行權限
    # chown $apache_user config.ini
    # chmod 0400 confing.ini

    到目前為止,2-6點是INSTALL.txt內也有列出的幾項工作。
    照著做完之後,在roundcube設定內,就可以看見"休假"的頁籤了。

  7. 不過你可能會遇到點下"休假"的頁籤後畫面就錯誤的狀況,這時候去檢查/roundcube/logs/errors時,可能會有以下錯誤訊息:
    PHP Fatal error: 
    Call to undefined function ssh2_connect() in …/roundcube/plugins/vacation/lib/sshftp.class.php on line ...
  8. 因為要使用PHP的SSH2系列功能時,系統需要有OpenSSL, libssh2, pecl-ssh2三個套件,可從ports安裝,libssh2與pecl-ssh2的位置分別在:
    libssh2: /usr/ports/security/libssh2
    pecl-ssh2:  /usr/ports/security/pecl-ssh2
    分別進入這兩個資料夾,設定並安裝:
    # make config install clean
    完成安裝後,可用phpinfo();網頁檢視SSH模組是否已支援。
    或是檢視/usr/local/etc/php/extensions.ini檔案內是否有此行:
    extension=ssh2.so
  9. 修改/etc/ssh/sshd_config檔
    必須啟用sshd的password authentication方法(sshftp.class.php內的叫用才會成功),找到PasswordAuthentication關進字並修改:

    # Change to yes to enable built-in password authentication.
    PasswordAuthentication yes

  10. 重新啟動sshd
    # /etc/rc.d/sshd restart
  11. 重新啟動apache
    # cd /usr/local/etc/rc.d
    ./apache restart
  12. try it!!

ref:

  1. [PHP] Secure Shell2
  2. [freeBSD] SSHD Man page

Tags