Help us understand the problem. What is going on with this article?

ArchLinux@RaspberryPiでGmail経由のメール送信

More than 5 years have passed since last update.

自分用設定手順メモ。
下記のページを参考にしました。(何となくでしか理解していません)
http://linuxaria.com/pills/how-to-configure-postfix-as-smtp-relay-for-gmail-on-archlinux?lang=en

必要パッケージのインストール

pacman -Sy postfix ca-certificates

Postfix設定ファイルの編集

nano /etc/postfix/main.cf

以下を追記。
hostname, domainnameは読み替え部分です。
元々書いてある該当行のコメントを外して編集してもOKです。

/etc/postfix/main.cf
myhostname = hostname # your host name
mydomain = domainname # your domain name
myorigin = $myhostname
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8

relayhost = [smtp.gmail.com]:587

header_checks = regexp:/etc/postfix/header_checks

smtp_generic_maps = hash:/etc/postfix/generic
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_enforce_tls = yes

disable_dns_lookups = yes

設定ファイル編集

Gmail認証設定

nano /etc/postfix/relay_password

以下の1行を書いてファイルを保存。

/etc/postfix/relay_passoword
[smtp.gmail.com]:587    youraccount@gmail.com:yourpassword

/etc/postfix/header_checks

nano /etc/postfix/header_checks

下記の行を追記。
hostname, domainname, youraccountは読み替え部分です。

/etc/postfix/header_checks
/^To:.*@hostname.localnet/ REDIRECT youraccount@gmail.com 
/^From:(.*@domainname[>]*)/ PREPEND Reply-To:$1

/etc/postfix/generic

nano /etc/postfix/generic

下記の行を追記。
例によってhostname, domainname, youraccountは読み替え部分です。

/etc/postfix/generic
root@domainname           youraccount@gmail.com
root@hostname.localnet    youraccount@gmail.com
user@hostname.localnet    youraccount@gmail.com

設定の反映等

次のコマンドを実行

postmap /etc/postfix/generic
postmap /etc/postfix/relay_password
cat /etc/ssl/certs/Equifax_Secure_CA.pem >/etc/postfix/cacert.pem

Postfix起動

systemctl start postfix

自動起動設定

systemctl enable postfix

テスト送信

echo "body of the message" | mail -r "youraccount@gmail.com" -s "TEST MAIL" to@email.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした