質問編集履歴
4
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,7 +29,28 @@
|
|
29
29
|

|
30
30
|
これを参考にして以下のコードを追記しました。
|
31
31
|
```ruby
|
32
|
+
require 'net/smtp'
|
33
|
+
require 'mail'
|
34
|
+
|
35
|
+
a = Net::SMTP.new("smtp.sendgrid.net", 587)
|
36
|
+
a.enable_starttls
|
37
|
+
a.start('localhost'){|smtp|
|
38
|
+
smtp.authenticate("id","password")
|
39
|
+
smtp.send_message(<<-EndOfMail, '送信元', '送信先')
|
40
|
+
From: Your Name <from@example.com>
|
41
|
+
To: Dest Address <to@example.net>
|
42
|
+
Subject: test mail
|
43
|
+
Date: Sat, 23 Jun 2019 18:20:50 +0900
|
44
|
+
Message-Id: <unique.message.id.string@yourhost.example.com>
|
45
|
+
|
46
|
+
ここにファイルを添付させるコードを記入
|
32
47
|
#{mail = Mail.new do add_file "./aaa.jpg" end}
|
48
|
+
This is a test mail.
|
49
|
+
EndOfMail
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
|
33
54
|
```
|
34
55
|
aaa.jpgを添付しています。以下ファイル構成(実行するのはsample.rb)
|
35
56
|

|
3
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
|
7
7
|
a = Net::SMTP.new("smtp.sendgrid.net", 587)
|
8
8
|
a.enable_starttls
|
9
|
-
a.start('
|
9
|
+
a.start('localhost'){|smtp|
|
10
10
|
smtp.authenticate("id","password")
|
11
|
-
smtp.send_message(<<-EndOfMail, '
|
11
|
+
smtp.send_message(<<-EndOfMail, '送信元', '送信先')
|
12
12
|
From: Your Name <from@example.com>
|
13
13
|
To: Dest Address <to@example.net>
|
14
14
|
Subject: test mail
|
2
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,8 +32,7 @@
|
|
32
32
|
#{mail = Mail.new do add_file "./aaa.jpg" end}
|
33
33
|
```
|
34
34
|
aaa.jpgを添付しています。以下ファイル構成(実行するのはsample.rb)
|
35
|
-

|
36
|
-
|
37
36
|
プログラムを実行すると・・・
|
38
37
|
以下のようなメールが送られてきます。
|
39
38
|

|
1
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
a = Net::SMTP.new("smtp.sendgrid.net", 587)
|
8
8
|
a.enable_starttls
|
9
9
|
a.start('matsukazu0409@gmail.com'){|smtp|
|
10
|
-
smtp.authenticate("
|
10
|
+
smtp.authenticate("id","password")
|
11
11
|
smtp.send_message(<<-EndOfMail, 'matsukazu0409@gmail.com', 'matsu-kazu4@ezweb.ne.jp')
|
12
12
|
From: Your Name <from@example.com>
|
13
13
|
To: Dest Address <to@example.net>
|