GithubHelp home page GithubHelp logo

sendgrid-sender's Introduction

Sendgrid Buffalo Sender

This is a buffalo sender for the Sendgrid email service.

How to use

In your mailers.go

import (
    ... 
    ssender "github.com/paganotoni/sendgrid-sender"
)

var sender mail.Sender

func init() {
	APIKey := envy.Get("SENDGRID_API_KEY", "")
	sender = ssender.NewSendgridSender(APIKey)
}

And then in your mailers you would do the same sender.Send(m) as this sender matches buffalos mail.Sender interface.

Add Custom Args

To add custom args, you must add values using CustomArgs type and add it into Message.Data ussing CustomArgsKey key

CustomArgsKey = "sendgrid_custom_args_key"
...
type CustomArgs map[string]string

How to use Sendgrid customargs

One thing you could need is to add customArgs to the message you're sending through sendgrid, to do this you would be using SetCustomArgs function, passing your mail.Messagewith the CustomArgs you want to add.

import (
	...
    ssender "github.com/paganotoni/sendgrid-sender"
)

func main() {
	APIKey := envy.Get("SENDGRID_API_KEY", "")
    sender = ssender.NewSendgridSender(APIKey)

	m := mail.NewMessage()
    ...
    ssender.SetCustomArgs(m, ssender.CustomArgs{
        "custom_arg_0": "custom_value_0",
        "custom_arg_1": "custom_value_1",
        ...
    })

    if err := sender.Send(m); err != nil{
        ...
    }
}

Test mode

Whenever the GO_ENV variable is set to be test this sender will use mocksmtp sender to send messages, you can read values in your tests within the property TestSender of the SendgridSender.

sendgrid-sender's People

Contributors

0xfeeddeadbeef avatar dmuriel avatar hdm avatar paganotoni avatar tatang26 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sendgrid-sender's Issues

Bump Buffalo dependency to 0.13.x

It would be great if the Gopkg.toml dependency for buffalo could be bumped to a 0.13.x version (0.13.6 current), as it currently causes buffalo build to fail when using 0.13.x with this package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.