DAITEI's blog
|
$ sudo apt install postfix procmail $ sudo dpkg -i sasl-xoauth2_0.20-1_amd64.deb sasl-xoauth2-tool_0.20-1_amd64.deb※ sasl-xoauth2 は debian experimental にある sasl-xoauth2 (0.20-1)を使用しました(R7年5月1日(木)現在 debian packageとしては、そこにしかない...)。
$ sudo dpkg-reconfigure postfix
| 項目 | 設定 | 備考 |
|---|---|---|
| General mail configuration type | スマートホスト付きインターネット Internet with smarthost | メールはSMTPを使用して直接受信するか、fetchmailなどのユーティリティを実行して受信します。送信メールはスマートホストを使用して送信されます。 Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost. |
| System mail name | (PCローカルHOST名に合わせる) | |
| SMTP relay host | [smtp.gmail.com]:587 | Please specify a domain, host, host:port, [address] or [address]:port. |
| Recipient for root and postmaster mail | (PCローカルのユーザー名) | Mail for the 'postmaster', 'root', and other system accounts needs to be redirected to the user account of the actual system administrator. |
| メールを受け取るほかの宛先 (なければ空) | (空) | このマシンが最終的な宛先と見なされるドメインのリストを、コンマで区切って指定してください。 |
| Local networks: | 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 | Please specify the network blocks for which this host should relay mail. The default is just the local host, which is needed by some mail user agents. |
| Mailbox size limit (bytes) | 0 | A value of zero (0) means no limit. The upstream default is 51200000. |
| Local address extension character | (空) | To not use address extensions, leave the string blank. |
| 利用するインターネットプロトコル | IPv4 | すべて : IPv4 と IPv6 アドレス両方を使う, IPv6: IPv6 アドレスのみをリスンする, ipv4: IPv4 アドレスのみをリスンする, |
mailbox_command = /usr/bin/procmail -a "$EXTENSION"
# SMTP Client TLS security level: none|may|encrypt|... smtp_tls_security_level = encrypt # SASL XOAUTH2 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = smtp_sasl_mechanism_filter = xoauth2
[smtp.gmail.com]:587 YourMail@gmail.com:/etc/tokens/YourMail@gmail.com※ SecretなFILEなのでchown 600 しましょう。
{
"client_id": "*************-********************************.apps.googleusercontent.com",
"client_secret": "******-****************************"
}
認可サーバへの通信にproxyを使用する場合は、以下のようにproxy設定を記述する。
{
"client_id": "*************-********************************.apps.googleusercontent.com",
"client_secret": "******-****************************",
"proxy" : "http://proxy:8080"
}
※ SecretなFILEなのでchown 600 しましょう。
$ sasl-xoauth2-tool get-token gmail \
--client-id=*************-********************************.apps.googleusercontent.com \
--client-secret=******-**************************** \
--scope="https://mail.google.com/" \
/tmp/YourMail@gmail.com
$ sudo mkdir -p /var/spool/postfix/etc/tokens
$ sudo mv /tmp/YourMail@gmail.com /var/spool/postfix/etc/tokens
$ sudo chown -R postfix:postfix /var/spool/postfix/etc/tokens
※ chrootで実行している設定なので、/var/spool/postfix/ 以下をアクセスする為
$ sudo mkdir -p /var/spool/postfix/etc/ssl/certs $ sudo cp /etc/ssl/certs/ca-certificates.crt /var/spool/postfix/etc/ssl/certs/ca-certificates.crt※ chrootで実行している設定なので、/var/spool/postfix/ 以下をアクセスする為
$ sudo postmap /etc/postfix/sasl_passwd
$ sudo systemctl reload postfix
update: 2025/09/20 08:22 | path: /pub/software/mta
update: 2025/05/01 14:57 | path: /pub/software/mta
$ sudo dpkg-reconfigure exim4-config
| メールサーバ設定タイプ | スマートホストでメール送信; SMTPまたはfetchmailで受信する |
|---|---|
| システムメール名 | (PCローカルHOST名に合わせる) |
| SMTP入力接続をLISTENするIPアドレス | 127.00.1 ; ::1 |
| メールを受けとるその他の宛先 | (空) |
| メールをリレーするマシン | (空) |
| 送出スマートホスト | smtp.gmail.com::587 |
| 送出するメールのローカルメール名を隠す | いいえ |
| DNSクエリを最小限に | いいえ |
| ローカルメールの配送方法 | ホームディレクトリ内のMaildir形式 |
| 設定を小さなファイルに分割 | いいえ |
# Gmail smtp.gmail.com:account:password
### main/02_exim4-config_options ################################# disable_ipv6 = trueこれで、smtp.gmail.comのipv6 アドレスへのアクセスをしなくなる。
$ sudo update-exim4.conf $ sudo systemctl restart exim4
update: 2021/09/30 22:56 | path: /pub/software/mta