https://github.com/rgglez/fc-gomail
Event handler for Aliyun Function Compute. It sends email using the gomail module. Intended to be triggered by Aliyun MNS.
https://github.com/rgglez/fc-gomail
aliyun aliyun-fc go gomail handler mailer
Last synced: 2 months ago
JSON representation
Event handler for Aliyun Function Compute. It sends email using the gomail module. Intended to be triggered by Aliyun MNS.
- Host: GitHub
- URL: https://github.com/rgglez/fc-gomail
- Owner: rgglez
- License: bsd-3-clause
- Created: 2023-03-18T18:52:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-03T04:53:05.000Z (4 months ago)
- Last Synced: 2026-02-03T18:27:14.742Z (4 months ago)
- Topics: aliyun, aliyun-fc, go, gomail, handler, mailer
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fc-gomail
[](https://opensource.org/licenses/BSD-3-Clause)   
This event handler sends an email using the [Gomail](https://github.com/go-gomail/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](https://go.dev/) 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](https://www.alibabacloud.com/help/en/function-compute/latest/create-a-function) 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:
```javascript
{
"From":"",
"To":"",
"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:
```yaml
SMTP:
HOST: smtp.yourserver.com
PORT: 2525
LOGIN:
PASSWORD:
```
The load might look like this:
```go
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) 2026, Rodolfo González González.
Read the LICENSE file.