2021年8月9日月曜日

alfresco メール設定②-3 メール配送設定(postfix+getmail)

getmailで取得したメールをpostfixを経由して、alfrescoに配送します。

1.postfixをインストール・設定

有料版はsmtpの制御ができますが、community版はできません。送信先フォルダにスクリプトが設定された状態でそのまま配送すると、alfresco側で処理しきれず、配送エラーや0byte配送を起こします。そのため、postfixに遅延処理の設定を追加します

centos8 stream では標準でインストールされないため、インストール

main.cfを変更

sudo vi /etc/postfix/main.cf
myhostname = ☆☆☆.xxx.com
mydomain = xxx.com
inet_interfaces = localhost
relayhost = [xxx.com]:1025
#----- 以下 最後尾に記載 --------
# メールの最大サイズを変更
message_size_limit = 40960000

# 全てのメールに対して、1通送る事に○秒のsleep
smtp_destination_rate_delay = 5s
sudo systemctl start postfix.service
sudo systemctl enable postfix.service

2.メールサーバからメールを自動受信するためgetmailをインストール

①getmailをダウンロード・インストール

curl -LO http://pyropus.ca/software/getmail/old-versions/getmail-5.15.tar.gz
tar xzf getmail-5.15.tar.gz
cd getmail-5.15
sudo python2 setup.py install
cd ..
mkdir -m 0700 .getmail
cp /usr/share/doc/getmail-5.15/getmailrc-examples .getmail/getmailrc
sudo vi .getmail/getmailrc

②getmailの設定

[options]
# verbose = 0 # 詳細表示なし
# delete = true # POPしたメールはサーバから削除する
# message_log = ~/.getmail/log # ログを保存する場合は以下2行をコメントアウト
# message_log_verbose = true
# サーバーから全てのメールを取得するのを止める
read_all = false
# 一度に取得するメール数を制限(環境により、数を調整)
max_messages_per_session = 10

[retriever]
# POP3で受信する場合(有効)
#type = SimplePOP3Retriever

# POP3 over SSLで受信する場合
type = SimplePOP3SSLRetriever
# メールサーバ
server = xxxx.ne.jp #取得するメールサーバを指定
# ユーザ名
username = xxx@xxxx.ne.jp #ユーザー名を指定
# パスワード
password = xxxxxxxxx    #パスワードを指定

[destination]
type = MDA_external     #MDAと連携する
path = /usr/sbin/sendmail
# 配送先のアドレスを設定 arguments = ("-f", "%(sender)", "-i", "-bm", "mail@xxxx.com")

getmailはデーモンで動作しないため、crontabで定期実行 ex.5分毎

cron設定は、全ての設定が完了後実行します。

crontab -e
# 標準エラーの出力を無効可しないと配送エラーとなるため /dev/null 2>&1を追加
*/5 * * * * /usr/bin/getmail > /dev/null 2>&1

0 件のコメント:

コメントを投稿