質問編集履歴
2
エラーの原因と思われるコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,3 +47,315 @@
|
|
47
47
|
<hoge.hoge@gmail.com>を削除するとエラーはでません。この記述に間違いがあるのだと思いますが
|
48
48
|
|
49
49
|
<hoge.hoge@gmail.com>は必要なコードなので正しい記述を教えていただけませんでしょうか?
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
追記 メール送信をコンソールで試した結果です。
|
54
|
+
|
55
|
+
```ここに言語を入力
|
56
|
+
|
57
|
+
irb(main):003:0> RegisterMailer.next_payment(user).deliver_now
|
58
|
+
|
59
|
+
Rendering register_mailer/next_payment.html.erb within layouts/mailer
|
60
|
+
|
61
|
+
Rendered register_mailer/next_payment.html.erb within layouts/mailer (0.6ms)
|
62
|
+
|
63
|
+
Rendering register_mailer/next_payment.text.erb within layouts/mailer
|
64
|
+
|
65
|
+
Rendered register_mailer/next_payment.text.erb within layouts/mailer (0.1ms)
|
66
|
+
|
67
|
+
RegisterMailer#next_payment: processed outbound mail in 11.3ms
|
68
|
+
|
69
|
+
Sent mail to hoge.hoge@gmail.com (1519.8ms)
|
70
|
+
|
71
|
+
Date: Wed, 22 May 2019 11:09:16 +0900
|
72
|
+
|
73
|
+
From: =?UTF-8?B?44Ov44Oz44OA44O844Ky44O844OI6YGL5Za25bGA?=
|
74
|
+
|
75
|
+
To: hoge.hoge@gmail.com
|
76
|
+
|
77
|
+
Message-ID: <5ce4af4c8d9b9_4b03fa1468fb1102055c@ik1-301-10835.vs.sakura.ne.jp.mail>
|
78
|
+
|
79
|
+
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?=
|
80
|
+
|
81
|
+
Mime-Version: 1.0
|
82
|
+
|
83
|
+
Content-Type: multipart/alternative;
|
84
|
+
|
85
|
+
boundary="--==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e";
|
86
|
+
|
87
|
+
charset=UTF-8
|
88
|
+
|
89
|
+
Content-Transfer-Encoding: 7bit
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e
|
96
|
+
|
97
|
+
Content-Type: text/plain;
|
98
|
+
|
99
|
+
charset=UTF-8
|
100
|
+
|
101
|
+
Content-Transfer-Encoding: base64
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
6ZW36LC36YOo5ZKM5bqD44GV44G+DQoNCuOBk+OBruW6puOBr+OAgeaciOmh
|
106
|
+
|
107
|
+
jeWIqeeUqOaWmemHkeOBruOBiuaMr+OCiui+vOOBv+OBguOCiuOBjOOBqOOB
|
108
|
+
|
109
|
+
huOBlOOBluOBhOOBvuOBl+OBn+OAgg0KNiDmnIjjga7jgZTliKnnlKjjgYzj
|
110
|
+
|
111
|
+
gYTjgZ/jgaDjgZHjgovjgojjgYbjgavjgarjgorjgb7jgZfjgZ/jgIINCg0K
|
112
|
+
|
113
|
+
44K144Kk44OI44KS44GU5Yip55So44GE44Gf44Gg44GP44Gr44GvDQpodHRw
|
114
|
+
|
115
|
+
czovL3dvbmRlci1nYXRlLmNvbQ0K44GL44KJ44Ot44Kw44Kk44Oz44KS6KGM
|
116
|
+
|
117
|
+
44Gj44Gm44GP44Gg44GV44GE44CCDQo=
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e
|
122
|
+
|
123
|
+
Content-Type: text/html;
|
124
|
+
|
125
|
+
charset=UTF-8
|
126
|
+
|
127
|
+
Content-Transfer-Encoding: base64
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCiAgPGhlYWQ+DQogICAgPG1ldGEg
|
132
|
+
|
133
|
+
aHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7
|
134
|
+
|
135
|
+
IGNoYXJzZXQ9dXRmLTgiIC8+DQogICAgPHN0eWxlPg0KICAgICAgLyogRW1h
|
136
|
+
|
137
|
+
aWwgc3R5bGVzIG5lZWQgdG8gYmUgaW5saW5lICovDQogICAgPC9zdHlsZT4N
|
138
|
+
|
139
|
+
CiAgPC9oZWFkPg0KDQogIDxib2R5Pg0KICAgIOmVt+iwt+mDqOWSjOW6g+OB
|
140
|
+
|
141
|
+
leOBvg0KPGhyIC8+DQo8cD7jgZPjga7luqbjga/jgIHmnIjpoY3liKnnlKjm
|
142
|
+
|
143
|
+
lpnph5Hjga7jgYrmjK/jgorovrzjgb/jgYLjgorjgYzjgajjgYbjgZTjgZbj
|
144
|
+
|
145
|
+
gYTjgb7jgZfjgZ/jgII8L3A+DQo8cD42IOaciOOBruOBlOWIqeeUqOOBjOOB
|
146
|
+
|
147
|
+
hOOBn+OBoOOBkeOCi+OCiOOBhuOBq+OBquOCiuOBvuOBl+OBn+OAgjwvcD4N
|
148
|
+
|
149
|
+
Cg0KPFA+44K144Kk44OI44KS44GU5Yip55So44GE44Gf44Gg44GP44Gr44Gv
|
150
|
+
|
151
|
+
PGEgaHJlZj0iaHR0cHM6Ly93b25kZXItZ2F0ZS5jb20iPuOBk+OBoeOCiTwv
|
152
|
+
|
153
|
+
YT7jgYvjgonjg63jgrDjgqTjg7PjgpLooYzjgaPjgabjgY/jgaDjgZXjgYTj
|
154
|
+
|
155
|
+
gII8L1A+DQogIDwvYm9keT4NCjwvaHRtbD4NCg==
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
----==_mimepart_5ce4af4c8c429_4b03fa1468fb1102049e--
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
Net::SMTPFatalError: 555 5.5.2 Syntax error. k9sm26244107pfa.180 - gsmtp
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
コードは以下になります。
|
168
|
+
|
169
|
+
```ここに言語を入力
|
170
|
+
|
171
|
+
config/environments/production.rb
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
config.action_mailer.delivery_method = :smtp
|
176
|
+
|
177
|
+
config.action_mailer.raise_delivery_errors = true
|
178
|
+
|
179
|
+
config.action_mailer.smtp_settings = {
|
180
|
+
|
181
|
+
address: 'smtp.gmail.com',
|
182
|
+
|
183
|
+
port: 587,
|
184
|
+
|
185
|
+
user_name: ENV["GMAIL_USERNAME"], #送信元メールアドレス
|
186
|
+
|
187
|
+
password: ENV["GMAIL_PASSWORD"],
|
188
|
+
|
189
|
+
domain: 'smtp.gmail.com',
|
190
|
+
|
191
|
+
authentication: 'plain',
|
192
|
+
|
193
|
+
enable_starttls_auto: true
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
```ここに言語を入力
|
200
|
+
|
201
|
+
registers_controller.rb
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
def update
|
206
|
+
|
207
|
+
@time = Time.zone.now
|
208
|
+
|
209
|
+
@month = @time.month
|
210
|
+
|
211
|
+
if @month == 1
|
212
|
+
|
213
|
+
@last_month = 12
|
214
|
+
|
215
|
+
@next_month = 2
|
216
|
+
|
217
|
+
elsif @month == 12
|
218
|
+
|
219
|
+
@last_month = 11
|
220
|
+
|
221
|
+
@next_month = 1
|
222
|
+
|
223
|
+
else
|
224
|
+
|
225
|
+
@last_month = @time.month - 1
|
226
|
+
|
227
|
+
@next_month = @time.month + 1
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
@register_form = Admin::RegisterForm.new(Register.find_by(customer_id: params[:id]))
|
234
|
+
|
235
|
+
@register_form.assign_attributes(params[:form])
|
236
|
+
|
237
|
+
if @register_form.save
|
238
|
+
|
239
|
+
flash.notice = '更新しました。'
|
240
|
+
|
241
|
+
reg = Register.find_by(customer_id: params[:id])
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
if reg["rg_#{@last_month}"] == "退会"
|
246
|
+
|
247
|
+
if reg["rg_#{@month}"] == "在籍"
|
248
|
+
|
249
|
+
if reg["rg_#{@next_month}"] == "在籍"
|
250
|
+
|
251
|
+
user = Customer.find_by(id: params[:id])
|
252
|
+
|
253
|
+
RegisterMailer.new_payment(user).deliver_now
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
else
|
260
|
+
|
261
|
+
if reg["rg_#{@last_month}"] == "在籍"
|
262
|
+
|
263
|
+
if reg["rg_#{@month}"] == "在籍"
|
264
|
+
|
265
|
+
if reg["rg_#{@next_month}"] == "在籍"
|
266
|
+
|
267
|
+
user = Customer.find_by(id: params[:id])
|
268
|
+
|
269
|
+
RegisterMailer.next_payment(user).deliver_now #ここでエラー発生
|
270
|
+
|
271
|
+
elsif reg["rg_#{@month}"] == "在籍"
|
272
|
+
|
273
|
+
user = Customer.find_by(id: params[:id])
|
274
|
+
|
275
|
+
RegisterMailer.payment(user).deliver_now
|
276
|
+
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
redirect_to :admin_customers
|
288
|
+
|
289
|
+
else
|
290
|
+
|
291
|
+
flash.now.alert = '入力に誤りがあります。'
|
292
|
+
|
293
|
+
render action: 'edit'
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
```
|
302
|
+
|
303
|
+
```ここに言語を入力
|
304
|
+
|
305
|
+
app/mailers/register_mailer.rb
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
def next_payment(user)
|
310
|
+
|
311
|
+
@time = Time.zone.now
|
312
|
+
|
313
|
+
@month = @time.month
|
314
|
+
|
315
|
+
if @month == 1
|
316
|
+
|
317
|
+
@last_month = 12
|
318
|
+
|
319
|
+
@next_month = 2
|
320
|
+
|
321
|
+
elsif @month == 12
|
322
|
+
|
323
|
+
@last_month = 11
|
324
|
+
|
325
|
+
@next_month = 1
|
326
|
+
|
327
|
+
else
|
328
|
+
|
329
|
+
@last_mont = @time.month - 1
|
330
|
+
|
331
|
+
@next_month = @time.month + 1
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
@user = user
|
338
|
+
|
339
|
+
mail to: user.email,
|
340
|
+
|
341
|
+
subject: "ありがとうございます。"
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
```
|
346
|
+
|
347
|
+
```ここに言語を入力
|
348
|
+
|
349
|
+
app/mailers/apprication_mailer.rb
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
class ApplicationMailer < ActionMailer::Base
|
354
|
+
|
355
|
+
default from: '運営局'
|
356
|
+
|
357
|
+
layout 'mailer'
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
```
|
1
<hoge.hoge@gmail.com>の記述の有無がエラーの根源のようですが・・・
test
CHANGED
File without changes
|
test
CHANGED
@@ -39,3 +39,11 @@
|
|
39
39
|
|
40
40
|
|
41
41
|
どなたかご教授お願いいたします。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
追記
|
46
|
+
|
47
|
+
<hoge.hoge@gmail.com>を削除するとエラーはでません。この記述に間違いがあるのだと思いますが
|
48
|
+
|
49
|
+
<hoge.hoge@gmail.com>は必要なコードなので正しい記述を教えていただけませんでしょうか?
|