subcap

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 3 Imported by: 0

README

Capitalize your subject based on a given language

This is a simple middlware that makes use of the powerful golang.org/x/text/cases library. It will read the currently set subject of the mail.Msg and use the cases library to capitalize the subject based on the given language.

Example

package main

import (
	"fmt"
	"github.com/wneessen/go-mail"
	"github.com/wneessen/go-mail-middleware/subject_capitalize"
	"golang.org/x/text/language"
	"os"
)

func main() {
	m := mail.NewMsg(mail.WithMiddleware(subcap.New(language.English)))
	m.Subject("this is a test message")
	if err := m.WriteToFile("testmail.eml"); err != nil {
		fmt.Printf("failed to write mail message to file: %s\n", err)
		os.Exit(1)
	}
}

Documentation

Index

Constants

View Source
const Type mail.MiddlewareType = "subcap"

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware is the middleware struct for the capitalization middleware

func New

func New(l language.Tag) *Middleware

New returns a new Middleware and can be used with the mail.WithMiddleware method. It takes a language.Tag as input

func (Middleware) Handle

func (c Middleware) Handle(m *mail.Msg) *mail.Msg

Handle is the handler method that satisfies the mail.Middleware interface

func (Middleware) Type added in v0.0.4

func (c Middleware) Type() mail.MiddlewareType

Type returns the MiddlewareType for this Middleware

Jump to

Keyboard shortcuts

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