Skip to content

Event handler for Aliyun Function Compute. It sends email using the gomail module. Intended to be triggered by Aliyun MNS.

License

Notifications You must be signed in to change notification settings

rgglez/fc-gomail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fc-gomail

License GitHub all releases GitHub issues GitHub commit activity

This event handler sends an email using the Gomail module, in response of a trigger originated from the Aliyun MNS message service, where a message must be published by another program. It's written in Go for the Aliyun FC FaaS service. Use cases could be a notification service or a login confirmation.

It's intended to run from a custom Docker container sourced from Aliyun Container Service, so it implements a webserver on its own.

The message sent to Aliyun MNS must have this structure, in JSON:

{
   "From":"<from@email.address>",
   "To":"<to@email.address>",
   "Subject":"The subject of the message",
   "Body":"The body of the message"
}

Configuration

The configuration, in the case of the code in this repository, is based in a YAML file, which is loaded into a variable map.

The structure of the relevant part of the YAML must be like this:

SMTP:
  HOST: smtp.yourserver.com
  PORT: 2525
  LOGIN: <your login>
  PASSWORD: <your password>

The load might look like this:

conf := config{} 
cfg := conf.load()

Where conf is an struct and cfg the map containing the loaded YAML.

Of course, feel free to change this part as you need.

Notes

  • A sample Dockerfile in provided, which you might adjust to your use case.
  • A sample Makefile to compile the Go code is provided, which you might adjust to your use case.
  • The Makefile uses "handler" as the name of the compiled binary, so you must either use this name in your FC configuration, or make changes accordingly.
  • Aliyun refers to Alibaba Cloud Services, but this code can be easily adapted to run in AWS Lambda, for instance.

License

Copyright (c) 2023, Rodolfo González González.

Read the LICENSE file.

About

Event handler for Aliyun Function Compute. It sends email using the gomail module. Intended to be triggered by Aliyun MNS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published