Let’s make a custom email sender API by google apps script.
By this API you can send a custom email also you can send email templates.
Features and usages
- Totally free
- You can send any kind of email template
- You can connect with your google sheets.
- Much more
Let's make the API first
-
- Open google drive in your favorite browser. Click on the “New”, then select “google apps script”.
-
- You can rename the file if you want. (optional).
- Delete all pre-code.
-
- Past the google apps script code here which provide in below.
- Click the save icon.
- After saving the code you don’t see any alert icon on this part.(see in Image)
- Click on the deploy button.
Google Apps Script Code
// kodular coder
//kodularcoder.web.app
function doGet(){
return ContentService.createTextOutput("online");
}
function doPost(e) {
var body = e.parameter.body;
MailApp.sendEmail({
to: e.parameter.to,
subject: e.parameter.subject,
body: body,
htmlBody: body
});
return ContentService.createTextOutput("success");
};
-
- Then select “New deployment”.
- Then select “New deployment”.
-
- Click on the settings icon and select “Web App”.
-
- Choose how can access your API. In this case, we will choose “anyone” can access this code.
-
- Select “Anyone”.
-
- After selecting click on the “Deploy” button.
-
- Click “Authorize access” to give permission.
-
- Then select your account.
-
- Click on “advance”.
-
- Click on “Go to”.
-
- Click on “Allow”.
-
- Now click on copy. It’s your API key. Note this API another place.
- Click on “Done”.
- All done.
Let's move to kodular
-
- Open your kodular project.
- For testing, you need 3 components. ( Web, Button and Notifier );
-
- Past Your API key on web url section.
-
- Let’s move to block section.
- Copy our block in your project, and it’s ready to test.
NOTE: Don’t change the white mark section ( ! importent );
All file Link: Kodular coder- Custom Email Guide
Details: We send a post request in API by web component. If our request succeeded then we got “success” as a response content. Otherwise, the request is failed due to some basic reasons. Such as internet connection error, wrong email address, wrong API, etc.
If I have done something wrong, please let me know so that I can correct my mistake. Because I am not a professional.
Thank you all