現在、google cloud functionsでgmailの送信スクリプトを関数テストで実行したところ以下のエラーがでてしまい、先に進めません。解決策はありますでしょうか。ご教授いただけたら幸いです。
設定やソースコードは下記の動画を参考にしました。
参考url: https://www.youtube.com/watch?v=SuaHjAv5QJA
error
1出力 完了 2Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging Details: 3500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. 4 5ログ 利用できません
json
1# secret.josonファイルの中身です 2 3{'email':"メールアドレス", 4 'pass':"12桁のWindowsアプリパス"} 5
python
1import base64 2import smtplib 3from email.mime.text import MIMEText 4from email.utils import formatdate 5import json 6 7def create_message(from_addr, to_addr, bcc_addrs, subject, body): 8 msg = MIMEText(body) 9 msg['Subject'] = subject 10 msg['From'] = from_addr 11 msg['To'] = to_addr 12 msg['Bcc'] = bcc_addrs 13 msg['Date'] = formatdate() 14 return msg 15 16def send(from_addr, to_addrs, msg, my_pass): 17 smtpobj = smtplib.SMTP('smtp.gmail.com', 587) 18 smtpobj.ehlo() 19 smtpobj.starttls() 20 smtpobj.ehlo() 21 smtpobj.login(from_addr, my_pass) 22 smtpobj.sendmail(from_addr, to_addrs, msg.as_string()) 23 smtpobj.close() 24 25def job(): 26 with open('secret.json') as f: 27 info = json.load(f) 28 29 FROM_ADDRESS = info['email'] 30 MY_PASS = info['pass'] 31 32 TO_ADDRESS = '宛先メールアドレス' 33 BCC = '' 34 35 SUBJECT = 'test' 36 37 BODY = 'これは練習です' 38 39 msg = create_message(FROM_ADDRESS, TO_ADDRESS, BCC, SUBJECT, BODY) 40 send(FROM_ADDRESS, TO_ADDRESS, msg, MY_PASS) 41
あなたの回答
tips
プレビュー