forked from moegyver/lambda-mailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendfeedback.py
executable file
·40 lines (34 loc) · 1.26 KB
/
sendfeedback.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import print_function
import json
import requests
import boto3
import constants
def lambda_handler(event, context):
name = event['name']
contact = event['contact']
publish = event['publish']
message = event['message']
payload = { 'secret': RECAPTCHA_SECRET, 'response': event["recaptcha"] }
r = requests.post("https://www.google.com/recaptcha/api/siteverify", data=payload)
print(r.json())
if r.json()['success']:
client = boto3.client('ses')
client.send_email(Source=FROM,
Destination={ 'ToAddresses' : TO},
Message={
'Subject': {
'Data': 'New feedback from ' + name,
'Charset': 'UTF-8'
},
'Body': {
'Text': {
'Data': """Hi there!
%s has contacted you on your blog. %s had the following to say:
%s
%s can be contacted at: %s and had this to say about publishing: %s
Thank you.
""" % (name, name, message, name, contact, publish)
}
}
})
return r.json()