Linux Install

Android

Linux Tools

Linux AV

Linux Memo

WINDOWS

PROGRAM

動画 Memo

音楽 Memo

モバイルアプリ Memo

FILE FORMAT

PROTOCOL

DEVICE

BookMark

その他


ses   

aws ses で postfix からメールを送る方法

  • aws centos7
  • postfix

introduction

  • AWS EC2 インスタンスにpostfix を入れても外部には直でメールを出せない(1,2通は出せても制限がかかる)
  • SES という amazon の smtp を経由する必要がある
  • postfix と連携できるため、既存のアプリをそのまま移行できる

AWS側の設定

下記にアクセス
https://ap-northeast-1.console.aws.amazon.com/ses/home?region=ap-northeast-1#

制限解除

【左ペイン】→【Sending Statistics】
Server Name をメモる:email-smtp.ap-northeast-1.amazonaws.com ※1
Production Access が Sandbox の場合は 【Edit your account details 】をクリック
適切に項目を埋める
zabbix notify mail 等でOK

domain の所有確認

左ペイン 【Domains】
【Verify a New Domain」
ドメイン名を入れてDNS情報を入れる。
同じアカウントで R53 でDNS管理しているならそのまま入れてくれる
※ MX レコードにはチェックを入れるとメールがとどかなくなるので要れないこと

AMIアカウントの作成

左ペイン 【SMTP Settings】 → 【Create My SMTP Credentials】
【作成】
認証情報をメモる
SMTP ユーザー名: ※2
SMTP パスワード: ※3

install

sudo yum -y install postfix cyrus-sasl-plain

postfix の設定

sudo postconf -e "relayhost = [email-smtp.ap-northeast-1.amazonaws.com]:587" \
"smtp_sasl_auth_enable = yes" \
"smtp_sasl_security_options = noanonymous" \
"smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" \
"smtp_use_tls = yes" \
"smtp_tls_security_level = encrypt" \
"smtp_tls_note_starttls_offer = yes" \
"smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt"

送信元アドレスの設定

sudo postconf -e "mynetworks = 192.168.0.0/24, localhost, 127.0.0.1"

SASL 情報

/etc/postfix/sasl_passwd

[email-smtp.ap-northeast-1.amazonaws.com]:587 【※2】:【※3】
sudo postmap hash:/etc/postfix/sasl_passwd
sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db 
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo systemctl enable postfix.service
sudo systemctl restart postfix

メール送信テスト

ドメイン認証しているアドレスからでないとダメ

sendmail -f 【送信元アドレス】 【送信元アドレス】
From: 【送信元アドレス】
Subject: test mail
test
.