fc-gomail

module
v0.0.0-...-42c8130 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: BSD-3-Clause

README

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL