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

telnetからSMTPを使ってメール送信

More than 3 years have passed since last update.

yahooのメールにtelnetからSMTPを使ってメール送信してみます。

$ telnet smtp.mail.yahoo.co.jp 25
Trying 183.79.29.237...
telnet: connect to address 183.79.29.237: Connection refused
telnet: Unable to connect to remote host

はい。Connection refusedされましたね。
これはプロバイダがOutbound Port 25 Blockingをかけているからです。
なので、サブミッションポートの587を指定して繋ぎます。

$ telnet smtp.mail.yahoo.co.jp 587
Trying 183.79.29.237...
Connected to smtp.mail.g.yahoo.co.jp.
Escape character is '^]'.
220 smtp526.mail.kks.yahoo.co.jp ESMTP
EHLO localhost
250-smtp526.mail.kks.yahoo.co.jp
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250 8BITMIME
MAIL FROM:自分のメールアドレス
530 Sorry, please use SMTP-AUTH instead - for help go to http://www.yahoo-help.jp/app/answers/detail/a_id/79799/p/622
Connection closed by foreign host.

はい。Connection closedされました。
エラーメッセージからもわかるように、SMTP-Auth(SMTP認証)が必要です。
なので、以下のコマンドを使って認証用の文字列を生成します。

printf "%s\0%s\0%s" メールアドレス メールアドレス パスワード | openssl base64 -e | tr -d '\n'; echo

で、出力された認証用文字列をコピーしておきます。

telnet smtp.mail.yahoo.co.jp 587
Trying 183.79.29.237...
Connected to smtp.mail.g.yahoo.co.jp.
Escape character is '^]'.
220 smtp530.mail.kks.yahoo.co.jp ESMTP
EHLO localhost
250-smtp530.mail.kks.yahoo.co.jp
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250 8BITMIME
AUTH PLAIN 認証用文字列
235 ok, go ahead (#2.0.0)
MAIL FROM:送信元メールアドレス
250 ok
RCPT TO:送信先メールアドレス
250 ok
DATA
354 go ahead
Subject: hoge
From: 送信元メールアドレス
To: 送信先メールアドレス

hello!
.
250 ok 1454173930 qp 24032
quit
221 smtp531.mail.kks.yahoo.co.jp
Connection closed by foreign host.

で、yahooメールを見てみるとメールが届いているのが分かります。

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