zeptomail

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 10 Imported by: 0

README

go-zeptomail

go-zeptomail is a Go library for sending emails using the ZeptoMail API with HTML templates.

Installation

You can install the package using go get:

go get github.com/blessedmadukoma/go-zeptomail

Setup

Rename the .env.example to .env and replace the dummy data with your ZeptoMail credentails

Usage:

package main

import (
    "fmt"
    zeptomail "github.com/blessedmadukoma/go-zeptomail"
)

func main() {
  // smtp uses the ZeptoMail configurations provided in your dashboard. Store in .env file
  smtp := zeptomail.SMTP{
    Host: "smtp.zeptomail.com",
    Port: 465,
    Username: "zeptomailusername",
    Password: "zeptomailpassword",
    SenderEmail: "zeptomail@mail.com",
  }

  // payload for the send email request
  data := zeptomail.MailData{
    RecipientName:  "Your recepient name",
    RecipientEmail: "email@mail.com",
    TemplateFile:   "welcome.html",
  }
    
  // creates a new zeptomail instance
  client := zeptomail.New(smtp)

  // sends the email to the recipient's email address and check for error if any
  if err := client.Send(data); err != nil {
      fmt.Println(err)
      return
  }
}

Contributing

If you'd like to contribute to this project, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and test them thoroughly.
  4. Commit your changes with clear commit messages.
  5. Push your changes to your fork.
  6. Create a pull request to the main repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  1. Thanks to ZeptoMail for providing the email-sending service.
  2. This project is maintained by Blessed Madukoma.

Documentation

Overview

Package zeptomail provides a Go client for sending emails using the ZeptoMail API.

See examples and usage details on GitHub: https://github.com/blessedmadukoma/go-zeptomail

To use, create a client with your API key, construct an email, and send it.

Example:

smtp := zeptomail.SMTP{...}
client := zeptomail.New(smtp)
data := zeptomail.MailData{...}
err := client.Send(data)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplate

func LoadTemplate(fileName string) (*template.Template, error)

LoadTemplate loads a template from the user's local 'templates' directory.

Types

type MailData

type MailData struct {
	RecipientName  string
	RecipientEmail string
	TemplateFile   string
}

type Mailer

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

func New

func New(smtp SMTP) Mailer

New initializes a new mail.Dialer instace

func (Mailer) Send

func (m Mailer) Send(data MailData) (message string, err error)

Send() takes a data containing the recipient email address, file name containing the templates, and any dynamic data for the templates

type SMTP

type SMTP struct {
	Host        string
	Port        int
	Username    string
	Password    string
	SenderEmail string
}

Jump to

Keyboard shortcuts

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