差分

移動: 案内検索

CentOS7(postfix)でSMTPにmailgunを使う方法

1,451 バイト追加2020年1月9日 (木) 01:31
ページの作成:「= CentOS7(postfix) で SMTP に mailgun を使う方法 = == 概要 == サーバ自身からではなく外部の SMTP サーバ(mailgun)を用いてメールを送信...」
= CentOS7(postfix) で SMTP に mailgun を使う方法 =

== 概要 ==

サーバ自身からではなく外部の SMTP サーバ(mailgun)を用いてメールを送信する環境を構築する。

== 手順 ==

=== 必要なパッケージをインストール ===

<pre># yum install postfix cyrus-sasl-plain cyrus-sasl-md5 mailx</pre>
=== main.cf 編集 ===

<pre># cp -p /etc/postfix/main.cf /etc/postfix/main.cf.org
# vi /etc/postfix/main.cf</pre>
以下を末尾に追記。

<pre>### mailgun settings.
relayhost = smtp.mailgun.org
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = AUTH LOGIN</pre>

=== sasl_passwd 作成・読み込み ===

<pre># MY_DOMAIN=&quot;example.jp&quot;
# MAILGUN_CREDENTIALS=&quot;012345abc1a234d567890b12345abc0-123a1b45-c1234567&quot;
# echo 'smtp.mailgun.org postmaster@${MY_DOMAIN}:${MAILGUN_CREDENTIALS}' &gt; /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd
# postmap /etc/postfix/sasl_passwd
# systemctl restart postfix</pre>
以上で、mail コマンド等で mailgun 経由でメールを送信できるようになった。

== 参考・引用 ==

https://blog.birkhoff.me/send-email-thru-mailgun-on-centos-7/

[[Category:Postfix]][[Category:OS]][[Category:Linux]][[Category:フリーソフト・オープンソース]][[Category:mailgun]]