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

opensslコマンドでAWS SESを経由でメール送信テスト

More than 1 year has passed since last update.

AWSのSimple Email Service(SES)ではUse Transport Layer Security (TLS)を使わないいけないので、簡単にtelnetから接続できません。
下記はサーバーから送信できるかどうかを試してみる手順です。

SMTP credentialsトークンの生成

$ perl -MMIME::Base64 -e 'print encode_base64("auth-user-name");'
QUtJ...auth-user....RMSUE=
$ perl -MMIME::Base64 -e 'print encode_base64("auth-password");'
QXVDR...auth-pass....3Q= 

メール送信

$ openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.us-west-2.amazonaws.com:587
depth=2 C = US, O = "VeriSign, Inc.", OU = VeriSign Trust Network, OU = "(c) 2006 VeriSign, Inc. - For authorized use only", CN = VeriSign Class 3 Public Primary Certification Authority - G5
verify return:1
depth=1 C = US, O = Symantec Corporation, OU = Symantec Trust Network, CN = Symantec Class 3 Secure Server CA - G4
verify return:1
depth=0 C = US, ST = Washington, L = Seattle, O = "Amazon.com, Inc.", CN = email-smtp.us-west-2.amazonaws.com
verify return:1
250 Ok
EHLO smtp.example.com                              # ← 入力
250-email-smtp.amazonaws.com
250-8BITMIME
250-SIZE 10485760
250-STARTTLS
250-AUTH PLAIN LOGIN
250 Ok
AUTH LOGIN                                        # ← 入力
334 VXNlcm5hbWU6
QUtJ...auth-user....RMSUE=                        # ← 入力
334 UGFzc3dvcmQ6
QXVDR...auth-pass....3Q=                          # ← 入力
235 Authentication successful.
MAIL FROM: info@example.com                       # ← 入力
250 Ok
rcpt TO: test@example.com                         # ← 入力
250 Ok
DATA                                              # ← 入力
354 End data with <CR><LF>.<CR><LF>
From: info@example.com                            # ← 入力
Subject: SES TEST                                 # ← 入力
Hello World                                       # ← 入力
.                                                 # ← 入力
250 Ok 0101015af9158693-aec4e9fe-5e1f-4211-826a-f9ca21411aac-000000
421 Timeout waiting for data from client.         # 入力せずにtimeout

メール確認

Delivered-To: test@example.com
Received: by .........;
        Wed, 22 Mar 2017 19:53:43 -0700 (PDT)
X-Received: by .......
....
From: info@example.com 
Subject: SES TEST
Message-ID: <0101015af9158693-aec4e9fe-5e1f-4211-826a-f9ca21411aac-000000@us-west-2.amazonses.com>
Date: Thu, 23 Mar 2017 02:53:42 +0000
X-SES-Outgoing: 2017.03.23-54.240.27.29
Feedback-ID: 1.us-west-2.jj20/+c1csFRX4yd6JTZjvVI/J8oJxtSw+150dH6qcs=:AmazonSES

Hello World

参考

http://qiita.com/tasaki-i3/items/e5ce2a235a4eb75c6d9b

Why do not you register as a user and use Qiita more conveniently?
  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
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