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

Gmailにopensslで接続してhtmlメールを送る

More than 5 years have passed since last update.

GmailをSMTPサーバとして利用する方法です。

  • openssl s_client -connect smtp.gmail.com:465 -crlf -ign_eof
    • -ign_eofがないと、以下のエラーでRCPT TO後に死ぬ

RENEGOTIATING
21874:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:/SourceCache/OpenSSL098/OpenSSL098-50/src/ssl/s3_pkt.c:543:

  • opensslでセッションを開始したあとの対話は以下のように進みます
EHLO localhost #ユーザー入力
250-mx.google.com at your service, [106.138.98.200]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
250-ENHANCEDSTATUSCODES
250 CHUNKING
AUTH LOGIN #ユーザー入力
334 xxxxxxx
xxxxxxxxxxxxxxxxx #ユーザー入力、認証(user)
334 xxxxxxx
xxxxxxxxxxxxxxxxx #ユーザー入力、認証(pass)
235 2.7.0 Accepted
MAIL FROM: <xxx@gmail.com> #ユーザー入力
250 2.1.0 OK fe3sm63961472pbd.66 - gsmtp
RCPT TO: <xxxx@example.com> #ユーザー入力
250 2.1.5 OK fe3sm63961472pbd.66 - gsmtp
DATA #ユーザー入力
354  Go ahead fe3sm63961472pbd.66 - gsmtp
Subject: test_html #ユーザー入力
Mime-Version: 1.0; #ユーザー入力
Content-Type: text/html; charset="ISO-8859-1"; #ユーザー入力
Content-Transfer-Encoding: 7bit; #ユーザー入力

<!DOCTYPE HTML>
<html lang="ja-JP">
<body>
<h1>はろーはろー</h1>
</body>
<html>
.

はまったところ

以下を参考にしました

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
ユーザーは見つかりませんでした