SMTPとPOP以外のメールに関する知識は皆無です。
本当に基礎が理解できていません。
ご了承ください。
Rubyでメールを送りたいです。
リファレンス
を参考を参考に作りました。
ruby
1require 'net/smtp' 2 3Net::SMTP.start('smtp.exmaple.com', 25) {|smtp| 4 smtp.open_message_stream('from@example.com', 'to@example.net') {|f| 5 f.puts 'From: from@example.com' 6 f.puts 'To: to@example.net' 7 f.puts 'Subject: test mail' 8 f.puts 9 f.puts 'This is test mail.' 10 } 11}
質問1
ruby
1smtp.open_message_stream('from@example.com', 'to@example.net')
上記の中に
ruby
1from@example.comやto@example.net
とありますが
この@に続くものは
そのメールのアカウントを管理しているサーバー(会社?)のドメイン
であり、
例えば下記
ruby
1sample@ezweb.ne.jp
上記のものはezweb.ne.jpというドメイン(会社?)が保有している
sampleという名前のアカウントである・・・ということですか?
質問2
上記のことを踏まえて自分のメールアドレスから自分へ送るように
改変させてみました。
ruby
1require 'net/smtp' 2 3Net::SMTP.start('222.15.69.195', 25) {|smtp| 4 smtp.open_message_stream('matsu-kazu4@ezweb.ne.jp', 'matsu-kazu4@ezweb.ne.jp') {|f| 5 f.puts 'From: from@ezweb.ne.jp' 6 f.puts 'To: to@ezweb.ne.jp' 7 } 8}
(認証とかで実際には送れないみたいだが・・・)
一応使い方としては合っていますでしょうか?
ruby
1Net::SMTP.start('222.15.69.195', 25) {|smtp|
上記のアドレスは
ruby
1>nslookup ezweb.ne.jp 2サーバー: apdcfb02e4bc3a 3Address: 192******** 4 5権限のない回答: 6名前: ezweb.ne.jp 7Address: 222.15.69.195
nslookupコマンドで調べました。
分からないので参考になるリンクまたは説明をお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/04 16:13