質問編集履歴
2
エラーの原因と思われるコードを追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -22,4 +22,160 @@
|
|
22
22
|
|
23
23
|
追記
|
24
24
|
<hoge.hoge@gmail.com>を削除するとエラーはでません。この記述に間違いがあるのだと思いますが
|
25
|
-
<hoge.hoge@gmail.com>は必要なコードなので正しい記述を教えていただけませんでしょうか?
|
25
|
+
<hoge.hoge@gmail.com>は必要なコードなので正しい記述を教えていただけませんでしょうか?
|
26
|
+
|
27
|
+
追記 メール送信をコンソールで試した結果です。
|
28
|
+
```ここに言語を入力
|
29
|
+
irb(main):003:0> RegisterMailer.next_payment(user).deliver_now
|
30
|
+
Rendering register_mailer/next_payment.html.erb within layouts/mailer
|
31
|
+
Rendered register_mailer/next_payment.html.erb within layouts/mailer (0.6ms)
|
32
|
+
Rendering register_mailer/next_payment.text.erb within layouts/mailer
|
33
|
+
Rendered register_mailer/next_payment.text.erb within layouts/mailer (0.1ms)
|
34
|
+
RegisterMailer#next_payment: processed outbound mail in 11.3ms
|
35
|
+
Sent mail to hoge.hoge@gmail.com (1519.8ms)
|
36
|
+
Date: Wed, 22 May 2019 11:09:16 +0900
|
37
|
+
From: =?UTF-8?B?44Ov44Oz44OA44O844Ky44O844OI6YGL5Za25bGA?=
|
38
|
+
To: hoge.hoge@gmail.com
|
39
|
+
Message-ID: <5ce4af4c8d9b9_4b03fa1468fb1102055c@ik1-301-10835.vs.sakura.ne.jp.mail>
|
40
|
+
Subject: =?UTF-8?Q?=E5=88=A9=E7=94=A8=E6=96=99=E9=87=91=E3=81=AE=E3=81=8A=E6=8C=AF=E3=82=8A=E8=BE=BC=E3=81=BF=E3=81=82=E3=82=8A=E3=81=8C=E3=81=A8=E3=81=86=E3=81=94=E3=81=96=E3=81=84=E3=81=BE=E3=81=99=E3=80=82?=
|
41
|
+
Mime-Version: 1.0
|
42
|
+
Content-Type: multipart/alternative;
|
43
|
+
boundary="--==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e";
|
44
|
+
charset=UTF-8
|
45
|
+
Content-Transfer-Encoding: 7bit
|
46
|
+
|
47
|
+
|
48
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e
|
49
|
+
Content-Type: text/plain;
|
50
|
+
charset=UTF-8
|
51
|
+
Content-Transfer-Encoding: base64
|
52
|
+
|
53
|
+
6ZW36LC36YOo5ZKM5bqD44GV44G+DQoNCuOBk+OBruW6puOBr+OAgeaciOmh
|
54
|
+
jeWIqeeUqOaWmemHkeOBruOBiuaMr+OCiui+vOOBv+OBguOCiuOBjOOBqOOB
|
55
|
+
huOBlOOBluOBhOOBvuOBl+OBn+OAgg0KNiDmnIjjga7jgZTliKnnlKjjgYzj
|
56
|
+
gYTjgZ/jgaDjgZHjgovjgojjgYbjgavjgarjgorjgb7jgZfjgZ/jgIINCg0K
|
57
|
+
44K144Kk44OI44KS44GU5Yip55So44GE44Gf44Gg44GP44Gr44GvDQpodHRw
|
58
|
+
czovL3dvbmRlci1nYXRlLmNvbQ0K44GL44KJ44Ot44Kw44Kk44Oz44KS6KGM
|
59
|
+
44Gj44Gm44GP44Gg44GV44GE44CCDQo=
|
60
|
+
|
61
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e
|
62
|
+
Content-Type: text/html;
|
63
|
+
charset=UTF-8
|
64
|
+
Content-Transfer-Encoding: base64
|
65
|
+
|
66
|
+
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCiAgPGhlYWQ+DQogICAgPG1ldGEg
|
67
|
+
aHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7
|
68
|
+
IGNoYXJzZXQ9dXRmLTgiIC8+DQogICAgPHN0eWxlPg0KICAgICAgLyogRW1h
|
69
|
+
aWwgc3R5bGVzIG5lZWQgdG8gYmUgaW5saW5lICovDQogICAgPC9zdHlsZT4N
|
70
|
+
CiAgPC9oZWFkPg0KDQogIDxib2R5Pg0KICAgIOmVt+iwt+mDqOWSjOW6g+OB
|
71
|
+
leOBvg0KPGhyIC8+DQo8cD7jgZPjga7luqbjga/jgIHmnIjpoY3liKnnlKjm
|
72
|
+
lpnph5Hjga7jgYrmjK/jgorovrzjgb/jgYLjgorjgYzjgajjgYbjgZTjgZbj
|
73
|
+
gYTjgb7jgZfjgZ/jgII8L3A+DQo8cD42IOaciOOBruOBlOWIqeeUqOOBjOOB
|
74
|
+
hOOBn+OBoOOBkeOCi+OCiOOBhuOBq+OBquOCiuOBvuOBl+OBn+OAgjwvcD4N
|
75
|
+
Cg0KPFA+44K144Kk44OI44KS44GU5Yip55So44GE44Gf44Gg44GP44Gr44Gv
|
76
|
+
PGEgaHJlZj0iaHR0cHM6Ly93b25kZXItZ2F0ZS5jb20iPuOBk+OBoeOCiTwv
|
77
|
+
YT7jgYvjgonjg63jgrDjgqTjg7PjgpLooYzjgaPjgabjgY/jgaDjgZXjgYTj
|
78
|
+
gII8L1A+DQogIDwvYm9keT4NCjwvaHRtbD4NCg==
|
79
|
+
|
80
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e--
|
81
|
+
|
82
|
+
Net::SMTPFatalError: 555 5.5.2 Syntax error. k9sm26244107pfa.180 - gsmtp
|
83
|
+
```
|
84
|
+
コードは以下になります。
|
85
|
+
```ここに言語を入力
|
86
|
+
config/environments/production.rb
|
87
|
+
|
88
|
+
config.action_mailer.delivery_method = :smtp
|
89
|
+
config.action_mailer.raise_delivery_errors = true
|
90
|
+
config.action_mailer.smtp_settings = {
|
91
|
+
address: 'smtp.gmail.com',
|
92
|
+
port: 587,
|
93
|
+
user_name: ENV["GMAIL_USERNAME"], #送信元メールアドレス
|
94
|
+
password: ENV["GMAIL_PASSWORD"],
|
95
|
+
domain: 'smtp.gmail.com',
|
96
|
+
authentication: 'plain',
|
97
|
+
enable_starttls_auto: true
|
98
|
+
}
|
99
|
+
```
|
100
|
+
```ここに言語を入力
|
101
|
+
registers_controller.rb
|
102
|
+
|
103
|
+
def update
|
104
|
+
@time = Time.zone.now
|
105
|
+
@month = @time.month
|
106
|
+
if @month == 1
|
107
|
+
@last_month = 12
|
108
|
+
@next_month = 2
|
109
|
+
elsif @month == 12
|
110
|
+
@last_month = 11
|
111
|
+
@next_month = 1
|
112
|
+
else
|
113
|
+
@last_month = @time.month - 1
|
114
|
+
@next_month = @time.month + 1
|
115
|
+
end
|
116
|
+
|
117
|
+
@register_form = Admin::RegisterForm.new(Register.find_by(customer_id: params[:id]))
|
118
|
+
@register_form.assign_attributes(params[:form])
|
119
|
+
if @register_form.save
|
120
|
+
flash.notice = '更新しました。'
|
121
|
+
reg = Register.find_by(customer_id: params[:id])
|
122
|
+
|
123
|
+
if reg["rg_#{@last_month}"] == "退会"
|
124
|
+
if reg["rg_#{@month}"] == "在籍"
|
125
|
+
if reg["rg_#{@next_month}"] == "在籍"
|
126
|
+
user = Customer.find_by(id: params[:id])
|
127
|
+
RegisterMailer.new_payment(user).deliver_now
|
128
|
+
end
|
129
|
+
end
|
130
|
+
else
|
131
|
+
if reg["rg_#{@last_month}"] == "在籍"
|
132
|
+
if reg["rg_#{@month}"] == "在籍"
|
133
|
+
if reg["rg_#{@next_month}"] == "在籍"
|
134
|
+
user = Customer.find_by(id: params[:id])
|
135
|
+
RegisterMailer.next_payment(user).deliver_now #ここでエラー発生
|
136
|
+
elsif reg["rg_#{@month}"] == "在籍"
|
137
|
+
user = Customer.find_by(id: params[:id])
|
138
|
+
RegisterMailer.payment(user).deliver_now
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
redirect_to :admin_customers
|
145
|
+
else
|
146
|
+
flash.now.alert = '入力に誤りがあります。'
|
147
|
+
render action: 'edit'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
```
|
152
|
+
```ここに言語を入力
|
153
|
+
app/mailers/register_mailer.rb
|
154
|
+
|
155
|
+
def next_payment(user)
|
156
|
+
@time = Time.zone.now
|
157
|
+
@month = @time.month
|
158
|
+
if @month == 1
|
159
|
+
@last_month = 12
|
160
|
+
@next_month = 2
|
161
|
+
elsif @month == 12
|
162
|
+
@last_month = 11
|
163
|
+
@next_month = 1
|
164
|
+
else
|
165
|
+
@last_mont = @time.month - 1
|
166
|
+
@next_month = @time.month + 1
|
167
|
+
end
|
168
|
+
|
169
|
+
@user = user
|
170
|
+
mail to: user.email,
|
171
|
+
subject: "ありがとうございます。"
|
172
|
+
end
|
173
|
+
```
|
174
|
+
```ここに言語を入力
|
175
|
+
app/mailers/apprication_mailer.rb
|
176
|
+
|
177
|
+
class ApplicationMailer < ActionMailer::Base
|
178
|
+
default from: '運営局'
|
179
|
+
layout 'mailer'
|
180
|
+
end
|
181
|
+
```
|
1
<hoge.hoge@gmail.com>の記述の有無がエラーの根源のようですが・・・
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,4 +18,8 @@
|
|
18
18
|
2行目に関しては「end」を記述するような構文でもないと思うし
|
19
19
|
3行目の関しては []や{}を使うような構文でもないのでエラーの原因がわかりません。
|
20
20
|
|
21
|
-
どなたかご教授お願いいたします。
|
21
|
+
どなたかご教授お願いいたします。
|
22
|
+
|
23
|
+
追記
|
24
|
+
<hoge.hoge@gmail.com>を削除するとエラーはでません。この記述に間違いがあるのだと思いますが
|
25
|
+
<hoge.hoge@gmail.com>は必要なコードなので正しい記述を教えていただけませんでしょうか?
|