質問するログイン新規登録

質問編集履歴

4

訂正

2019/08/15 13:17

投稿

kazuyakazuya
kazuyakazuya

スコア193

title CHANGED
File without changes
body CHANGED
@@ -29,7 +29,28 @@
29
29
  ![イメージ説明](7ffacc3f6dd05f6398544f2ccf52ef8e.png)
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
  ![イメージ説明](b258edf88eccafde143270ea5b27b6a9.png)

3

訂正

2019/08/15 13:17

投稿

kazuyakazuya
kazuyakazuya

スコア193

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('matsukazu0409@gmail.com'){|smtp|
9
+ a.start('localhost'){|smtp|
10
10
  smtp.authenticate("id","password")
11
- smtp.send_message(<<-EndOfMail, 'matsukazu0409@gmail.com', 'matsu-kazu4@ezweb.ne.jp')
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

訂正

2019/08/15 12:42

投稿

kazuyakazuya
kazuyakazuya

スコア193

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
- ![イメージ説明](9baf0510d6319f35c154abac7e5ae4a2.png)
35
+ ![イメージ説明](b258edf88eccafde143270ea5b27b6a9.png)
36
-
37
36
  プログラムを実行すると・・・
38
37
  以下のようなメールが送られてきます。
39
38
  ![イメージ説明](a0d925c87dbbdc6acdd4527c8e08057a.jpeg)

1

訂正

2019/08/15 12:30

投稿

kazuyakazuya
kazuyakazuya

スコア193

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("sgj042nf@kke.com","ggtxrw3m")
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>