Making use of Skygear Cloud Function to send form data to emails from static website (with simple HTML page templates)
DEMO - hosted at Skygear hosting
In the demo example, we are using a default email account from Gmail: margin.top.20px@gmail.com
to send testing mails. Which means: Quota may exeed.
Desipte using the default settings works, You are advised to fork and deploy your own version on Skygear, with custom email server settings (in settings.py). See how to set up here.
You can also custoimize the adaptor as you wish.
- Easily set up Cloud Function handler to send email via SMTP
- Google Recaptcha enabled by default
- Simple API call
- Custom SMTP server supported
- Embed into your static site easily
- Standalone and customizable static HTML page templates
These are available choices:
- Sendgrid
- Gmail
- Limit: 2000 messages per day
- If you have G Suite, you can sent to 10000 recipients per day
- Your own SMTP server
Gmail is recommended for low volume usage; and Sendgrid is recommended if you send massive emails.
- Sign up with Skygear to deploy the sender on your site
- Clone this repo
- Update settings accordingly in
settings.py
- Set up Google Recatpcha, requires API Key and secret to enable, update them in
settings.py
and html pagedata-sitekey
- Update the template UI as you wish
- Update Skygear API Endpoint and API Key (in HTML files)
- Deploy updated code to Skygear - using Skycli.
- Try it out! Hosted at
/static/
of your app path.
You can set up custom settings in settings.py.
If you find recaptcha unneccessary, you may turn if off by setting enable_grecaptcha
to False
.
config = {
"default_sender": "David Ng<me@davidng.hk>",
"default_reply_to": "me+skymail@davidng.hk",
"enable_grecaptcha": False,
"grecaptcha_secret": 'IGNORE THIS FIELD'
}
Update default_sender
as the address and name you wish to send as.
Update default_reply_to
as the reply-to address.
config = {
"default_sender": "Peter Smart<peter.smart@gmail.com>",
"default_reply_to": "reply.peter@gmail.com",
"enable_grecaptcha": True,
"grecaptcha_secret": 'ADD YOUR GOOGLE RECAPTCHA HERE'
}
- Subscription forms
- Sign up for more information
- Web app sign up confirmation
- Auto welcome email (using cloud functions part without the form)
- Receive support requests
- Cloud function using Python 3.6. Installation Guide.
- Initialize an virtual env for the first time. Follow this guide.
python3 -m venv env
source env/bin/activate
Note: If there is error when running pip install -r requirements.txt
on Python3.6
, you may need to use easy_install pyzmail
to install pyzmail instead.
- Using pyzmail for the SMTP mailing function - a neat and lightweight Python library.
Feel free to open any issue and PR. Contact at hello+skymail@skygear.io or fill in the form here.
Skygear is an open-source backend for apps. You can write plugins to enrich your application. Skymail is a perfect example to demostrate the use of cloud functions.
Besides sending emails, Skygear is suitable for writing simple or even database-connected cloud functions.