gophersmtp

package module
v0.0.0-...-b54bd16 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Author = "github.com/lordofthemind"

Author of the gophersmtp package

View Source
const Description = "Gophersmtp provides utilities for sending and receiving emails, supporting various SMTP features."

Description of the package

View Source
const Version = "1.0.1"

Version of the gophersmtp package

Variables

View Source
var EmailResultsChan = make(chan EmailResult)

Functions

This section is empty.

Types

type EmailResult

type EmailResult struct {
	Recipient string
	Error     error
}

type EmailRoutineService

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

EmailRoutineService introduces Go routines to enhance email sending efficiency.

func (*EmailRoutineService) ScheduleEmail

func (e *EmailRoutineService) ScheduleEmail(to []string, subject, body string, sendAt time.Time, isHtml bool) error

ScheduleEmail schedules an email to be sent at a specific time using a Go routine.

This function schedules an email to be sent at a future time.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • sendAt: The time at which the email should be sent.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendBulkEmail

func (e *EmailRoutineService) SendBulkEmail(to []string, subject, body string, isHtml bool) error

SendBulkEmail sends bulk emails using Go routines for each email.

This function sends multiple emails to the specified list of recipients by spinning up a Go routine for each.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendEmail

func (e *EmailRoutineService) SendEmail(to []string, subject, body string, isHtml bool) error

SendEmail sends an email to the recipients using a Go routine and reports results via channel.

This function sends a basic email to the specified recipients. It can handle either text or HTML content.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendEmailWithAttachments

func (e *EmailRoutineService) SendEmailWithAttachments(to []string, subject, body string, attachmentPaths []string, isHtml bool) error

SendEmailWithAttachments sends an email with attachments using a Go routine and reports results via channel.

This function sends an email with one or more file attachments to the specified recipients.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • attachmentPaths: A list of file paths for the attachments.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendEmailWithAttachmentsAndInLineImages

func (e *EmailRoutineService) SendEmailWithAttachmentsAndInLineImages(to []string, subject, body string, attachmentPaths, imagePaths []string) error

SendEmailWithAttachmentsAndInLineImages sends an email with both attachments and inline images using a Go routine.

func (*EmailRoutineService) SendEmailWithCCAndBCC

func (e *EmailRoutineService) SendEmailWithCCAndBCC(to, cc, bcc []string, subject, body string, isHtml bool) error

SendEmailWithCCAndBCC sends an email with CC and BCC recipients using a Go routine.

This function sends an email to the specified recipients, including CC and BCC recipients.

Params:

  • to: A list of recipient email addresses.
  • cc: A list of CC recipient email addresses.
  • bcc: A list of BCC recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendEmailWithCCAndBCCAndAttachments

func (e *EmailRoutineService) SendEmailWithCCAndBCCAndAttachments(to, cc, bcc []string, subject, body string, attachmentPaths []string, isHtml bool) error

SendEmailWithCCAndBCCAndAttachments sends an email with CC, BCC recipients, and attachments using a Go routine. The isHtml flag determines whether it's text or HTML, and the result is reported via a channel.

func (*EmailRoutineService) SendEmailWithHeaders

func (e *EmailRoutineService) SendEmailWithHeaders(to []string, subject, body string, headers map[string]string, isHtml bool) error

SendEmailWithHeaders sends an email with custom headers using a Go routine and reports results via channel.

This function sends an email with custom headers. It allows for additional headers like 'Reply-To' or 'From'.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • headers: A map of custom headers to include in the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailRoutineService) SendEmailWithInLineImages

func (e *EmailRoutineService) SendEmailWithInLineImages(to []string, subject, body string, imagePaths []string) error

SendEmailWithInLineImages sends an email with inline images using a Go routine.

This function sends an email that contains inline images to the specified recipients.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • imagePaths: A list of file paths for the inline images.

Returns:

  • error: An error message if the email fails to send.

type EmailService

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

EmailService is responsible for handling email sending with various functionalities such as sending plain text, HTML, attachments, and more.

func (*EmailService) ScheduleEmail

func (e *EmailService) ScheduleEmail(to []string, subject, body string, sendAt time.Time, isHtml bool) error

ScheduleEmail schedules an email to be sent at a specific time. The isHtml flag determines text or HTML format.

This function schedules the email to be sent at a specific time using a goroutine and timer to delay execution.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • sendAt: The time when the email should be sent.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the scheduling fails.

func (*EmailService) SendBulkEmail

func (e *EmailService) SendBulkEmail(to []string, subject, body string, isHtml bool) error

SendBulkEmail sends bulk emails. The isHtml flag determines text or HTML format.

This function is designed for sending the same email to multiple recipients in bulk. It can handle plain text and HTML emails based on the `isHtml` flag.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the bulk email fails to send.

func (*EmailService) SendEmail

func (e *EmailService) SendEmail(to []string, subject, body string, isHtml bool) error

SendEmail sends an email to the recipients. The isHtml flag determines whether it's text or HTML.

This function composes and sends a basic email to the specified recipients. It can send both plain text and HTML emails based on the `isHtml` flag.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithAttachments

func (e *EmailService) SendEmailWithAttachments(to []string, subject, body string, attachmentPaths []string, isHtml bool) error

SendEmailWithAttachments sends an email with attachments. The isHtml flag determines text or HTML format.

This function attaches one or more files to the email and sends it to the recipients. The email can be either plain text or HTML based on the `isHtml` flag.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • attachmentPaths: A list of file paths for the attachments.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithAttachmentsAndInLineImages

func (e *EmailService) SendEmailWithAttachmentsAndInLineImages(to []string, subject, body string, attachmentPaths []string, inlineImagePaths []string) error

SendEmailWithAttachmentsAndInLineImages sends an email with both attachments and inline images.

This function combines attachments and inline images into a single email. It supports sending both plain text and HTML content, and allows the inclusion of image references in the email body.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • attachmentPaths: A list of file paths for the attachments.
  • inlineImagePaths: A list of file paths for the inline images.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithCCAndBCC

func (e *EmailService) SendEmailWithCCAndBCC(to, cc, bcc []string, subject, body string, isHtml bool) error

SendEmailWithCCAndBCC sends an email with CC and BCC recipients. The isHtml flag determines text or HTML format.

This function sends an email with additional CC and BCC recipients. Both CC and BCC lists are supported to allow visibility and hidden recipients.

Params:

  • to: A list of recipient email addresses.
  • cc: A list of CC recipient email addresses.
  • bcc: A list of BCC recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithCCAndBCCAndAttachments

func (e *EmailService) SendEmailWithCCAndBCCAndAttachments(to, cc, bcc []string, subject, body string, attachmentPaths []string, isHtml bool) error

SendEmailWithCCAndBCCAndAttachments sends an email with CC, BCC recipients, and attachments. The isHtml flag determines whether it's text or HTML.

This function sends an email to the specified recipients, including CC, BCC recipients, and attaches one or more files to the email.

Params:

  • to: A list of recipient email addresses.
  • cc: A list of CC recipient email addresses.
  • bcc: A list of BCC recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • attachmentPaths: A list of file paths for the attachments.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithHeaders

func (e *EmailService) SendEmailWithHeaders(to []string, subject, body string, headers map[string]string, isHtml bool) error

SendEmailWithHeaders sends an email with custom headers. The isHtml flag determines text or HTML format.

This function allows setting custom headers such as priority, tracking, and metadata. The email can either be plain text or HTML based on the `isHtml` flag.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • headers: A map of custom headers.
  • isHtml: A flag indicating whether the email should be sent in HTML format.

Returns:

  • error: An error message if the email fails to send.

func (*EmailService) SendEmailWithInLineImages

func (e *EmailService) SendEmailWithInLineImages(to []string, subject, body string, inlineImagePaths []string) error

SendEmailWithInLineImages sends an email with inline images only.

This function allows embedding images directly into the email content. The email can either be plain text or HTML based on the `isHtml` flag.

Params:

  • to: A list of recipient email addresses.
  • subject: The subject of the email.
  • body: The content of the email.
  • inlineImagePaths: A list of file paths for the inline images.

Returns:

  • error: An error message if the email fails to send.

type GopherSmtpInterface

type GopherSmtpInterface interface {
	// SendEmail sends an email to the recipients. The isHtml flag determines whether it's text or HTML.
	SendEmail(to []string, subject, body string, isHtml bool) error

	// SendEmailWithAttachments sends an email with attachments. The isHtml flag determines text or HTML format.
	SendEmailWithAttachments(to []string, subject, body string, attachmentPaths []string, isHtml bool) error

	// SendEmailWithHeaders sends an email with custom headers. The isHtml flag determines text or HTML format.
	SendEmailWithHeaders(to []string, subject, body string, headers map[string]string, isHtml bool) error

	// ScheduleEmail schedules an email to be sent at a specific time. The isHtml flag determines text or HTML format.
	ScheduleEmail(to []string, subject, body string, sendAt time.Time, isHtml bool) error

	// SendEmailWithCCAndBCC sends an email with CC and BCC recipients. The isHtml flag determines text or HTML format.
	SendEmailWithCCAndBCC(to []string, cc []string, bcc []string, subject, body string, isHtml bool) error

	// SendBulkEmail sends bulk emails. The isHtml flag determines text or HTML format.
	SendBulkEmail(to []string, subject, body string, isHtml bool) error

	// SendEmailWithInLineImages sends an email with inline images.
	// Only applicable for HTML emails.
	SendEmailWithInLineImages(to []string, subject, body string, imagePaths []string) error

	// SendEmailWithCCAndBCCAndAttachments sends an email with CC, BCC, and attachments. The isHtml flag determines text or HTML format.
	SendEmailWithCCAndBCCAndAttachments(to []string, cc []string, bcc []string, subject, body string, attachmentPaths []string, isHtml bool) error

	// SendEmailWithAttachmentsAndInLineImages sends an email with both attachments and inline images.
	// Only applicable for HTML emails.
	SendEmailWithAttachmentsAndInLineImages(to []string, subject, body string, attachmentPaths, imagePaths []string) error
}

func NewEmailRoutineService

func NewEmailRoutineService(smtpHost, smtpPort, username, password string) GopherSmtpInterface

func NewEmailService

func NewEmailService(smtpHost, smtpPort, username, password string) GopherSmtpInterface

NewEmailService creates a new instance of EmailService with the given SMTP configurations. Parameters: - smtpHost: The host of the SMTP server. - smtpPort: The port of the SMTP server. - username: The sender's email address. - password: The sender's email account password (used for authentication).

Jump to

Keyboard shortcuts

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