LoginSignup
2
2

More than 5 years have passed since last update.

Procmailで転送先のGmailにエラーを吐かせない方法

Last updated at Posted at 2014-11-11

Procmailで作成するレシピ

  1. 添付ファイルがexeの場合、転送しない
  2. 添付ファイルが15MB以上の場合、転送しない

.forwadファイルを作成する

$ touch .forward
$ chmod 600 .forward
$ vi .forward

$HOME/.forward
{ユーザ名}
"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #{ユーザ名}"

.procmailrcファイルを作成する

$ vi .procmailrc

$HOME/.procmailrc
# ヘッダContent-Typeにexeが含まれたら削除
:0 
* ^Content-Type:.*name=.*\.exe.*
/dev/null

# メッセージ本体のfilenameにexeが含まれたら削除
:0B 
* .*filename=.*\.exe.*
/dev/null

# 15MB以下の場合、メールを転送する
:0 
* < 15000000
! {転送先Gmailアドレス}

テストする

  1. ただのテキストメールを送った場合
    → 転送されることを確認
  2. exe添付のメールを送った場合
    → 転送されないことを確認
  3. 15MB超えのメールを送った場合
    → 転送されないことを確認
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2