Categorygithub.com/common-go/mail
modulepackage
0.0.1
Repository: https://github.com/common-go/mail.git
Documentation: pkg.go.dev

# README

Mail

Email

Model

  • Mail

Service

  • MailService

Implementations

There are 2 implementations of MailService:

  • SMTP
  • SendGrid

Installation

Please make sure to initialize a Go module before installing core-go/mail:

go get -u github.com/core-go/mail

Import:

import "github.com/core-go/mail"

Details

mail_service.go

type MailService interface {
	Send(mail Mail) error
}

Example of SMTP

package main

import (
	"github.com/core-go/mail"
	"github.com/core-go/mail/smtp"
)

func main() {
	// Create a new smtp mail service 
	config := smtp.DialerConfig{"smtp.gmail.com", 587, "[email protected]", "test", true}
	mailService := smtp.NewSmtpMailSender(config)

	subject := "Your smtp demo"
	content := `Content of the email`

	mailFrom := mail.Email{Address: "[email protected]"}
	mailTo := []mail.Email{{Address: "[email protected]"}}
	mailData := mail.NewHtmlMail(mailFrom, subject, mailTo, nil, content)

	mailService.Send(*mailData)
}

Example of SendGrid

package main

import (
	"github.com/core-go/mail"
	"github.com/core-go/mail/sendgrid"
)

func main() {
	// Create a new sendgrid mail service 
	mailService := sendgrid.NewSendGridMailSender("xx.xxxxOQVcRKGxxxxk2KJc4g.fM7m9NIxxxxSLNOzxxxxfxF9bH4mnRrIysJA8q-xxxx")

	subject := "Your sendgrid demo"
	content := `Content of the email`

	mailFrom := mail.Email{Address: "[email protected]"}
	mailTo := []mail.Email{{Address: "[email protected]"}}
	mailData := mail.NewHtmlMail(mailFrom, subject, mailTo, nil, content)

	mailService.Send(*mailData)
}

# Packages

No description provided by the author
No description provided by the author

# Functions

EscapeName adds quotes around the name to prevent errors from RFC5322 special characters: ()<>[]:;@\,." To preserve backwards compatibility for people already quoting their name inputs, as well as for inputs which do not strictly require quoting, the name is returned unmodified if those conditions are met.
GetRequestBody ...
NewASM ...
NewAttachment ...
NewBCCSetting ...
NewClickTrackingSetting ...
NewContent ...
NewEmail ...
NewFooterSetting ...
NewGaSetting ...
No description provided by the author
NewMail ...
NewMailInit ...
NewMailSettings ...
No description provided by the author
No description provided by the author
NewOpenTrackingSetting ...
No description provided by the author
NewPersonalization ...
No description provided by the author
NewSandboxModeSetting ...
NewSetting ...
No description provided by the author
No description provided by the author
NewSingleEmail ...
NewSpamCheckSetting ...
NewSubscriptionTrackingSetting ...
No description provided by the author
No description provided by the author
NewTrackingSettings ...
ParseEmail parses a string that contains an rfc822 formatted email address and returns an instance of *Email.
No description provided by the author

# Structs

Asm contains Grpip Id and int array of groups ID.
Attachment holds attachement information.
BccSetting holds email bcc setings to enable of disable default is false.
ClickTrackingSetting ...
Content defines content of the mail body.
No description provided by the author
No description provided by the author
Email holds email name and address info.
FooterSetting holds enaable/disable settings and the format of footer i.e HTML/Text.
GaSetting ...
Mail contains mail struct.
MailSettings defines mail and spamCheck settings.
No description provided by the author
No description provided by the author
OpenTrackingSetting ...
No description provided by the author
Personalization holds mail body struct.
SandboxModeSetting ...
Setting enables the mail settings.
No description provided by the author
SpamCheckSetting holds spam settings and which can be enable or disable and contains spamThreshold value.
SubscriptionTrackingSetting ...
No description provided by the author
TrackingSettings holds tracking settings and mail settings.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author