回答編集履歴

1

追記

2019/08/15 15:32

投稿

otn
otn

スコア84616

test CHANGED
@@ -17,3 +17,47 @@
17
17
 
18
18
 
19
19
  ファイル添付のメールというのは、メール本文とファイルを一緒にした1つのメールを送ると言うことです。つまり、メールを受信した段階でファイルは受信済みです。クリックしてダウンロードするのでは無いです。
20
+
21
+
22
+
23
+ #追記
24
+
25
+ mail gemの使い方。自分でnet/smtpでメールする場合。
26
+
27
+ ```Ruby
28
+
29
+ require "net/smtp"
30
+
31
+ require "mail"
32
+
33
+
34
+
35
+ mail = Mail.new do
36
+
37
+ from "Your Name <from@example.com>"
38
+
39
+ to "Dest Address <to@example.net>"
40
+
41
+ subject "test mail"
42
+
43
+ body "This is a test mail."
44
+
45
+ add_file "./aaa.jpg"
46
+
47
+ end
48
+
49
+
50
+
51
+ a = Net::SMTP.new("smtp.sendgrid.net", 587)
52
+
53
+ a.enable_starttls
54
+
55
+ a.start('localhost') do |smtp|
56
+
57
+ smtp.authenticate("id","password")
58
+
59
+ smtp.send_message(mail.to_s, "送信元", "送信先")
60
+
61
+ end
62
+
63
+ ```