smtp

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 8 Imported by: 0

README

SMTP Setup

  1. Provide your email server and port settings in the config.yaml under providers.smtp.
  2. Comment out or leave username and password blank if using an unauthenticated smtp server.
  3. Add the from address and 1 or more to addresses.
  4. Optionally override the Email Subject.
  5. Optionaly provide a customTemplate (path to file). See Custom Template for more info.

Example Config

  smtp:
    enabled: true
    server: "smtp.gmail.com"
    port: "587"
    username: "mail@gmail.com"
    password: "abcdefghijklmno"
    subject: "AWS News"
    footer: "Brought to you by <a href='https://github.com/circa10a/go-aws-news'>go-aws-news</a>"
    from: "mail@gmail.com"
    to:
      - "some.email@mail.com"
      - "some.other@mail.com"
    # customTemplate: /path/to/email.html

Default Template

The default email template looks like this:

AWS News default email template

The footer can be customized in the config.yaml providers.smtp.footer. For more customization see custom template.

Custom Template

To provide a custom email html template, start with the defaultTemplate included in the code and build from there:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <style>
    .footer {
      text-align: center;
    }
    .footer p {
      margin-top: 40px;
    }
    </style>
  </head>
  <body>
    <h3>AWS News for {{ .Date }}:</h3>
    {{ .News }}
    <div class="footer">
      <p>{{ .Footer }}</p>
    </div>
  </body>
</html>

There are 3 keys available to use:

Date The date of yesterday's news.
News The AWS News in an unordered list of links.
Footer Custom footer (overridable in config.yaml )

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	Footer    string   `yaml:"footer"`
	Server    string   `yaml:"server"`
	Port      string   `yaml:"port"`
	Username  string   `yaml:"username"`
	Password  string   `yaml:"password"`
	Subject   string   `yaml:"subject"`
	From      string   `yaml:"from"`
	Template  string   `yaml:"customTemplate"`
	To        []string `yaml:"to"`
	IsEnabled bool     `yaml:"enabled"`
}

Provider is an implementation of the `go-aws-news/providers` Provider interface.

func (*Provider) Enabled

func (p *Provider) Enabled() bool

Enabled returns true if the provider is enabled in the config.

func (*Provider) GetName

func (*Provider) GetName() string

GetName returns the Provider's name.

func (*Provider) Notify

func (p *Provider) Notify(news news.Announcements)

Notify is the function executed to POST to a provider's webhook url.

Jump to

Keyboard shortcuts

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