envio de email via SMTP com anexo usando Go

Related tags

Email go golang email
Overview

gosendmail - SMTP

This repo is a simple net/smtp abstraction for sending emails using SMTP. With it we can send emails With copy, with blind copy and attachments. The body is plain text, we're still going to make a version to accept HTML, at the moment only text/plain in the Body. The attachment must pass the complete path so that the package can open the file. There are 4 environment variables to be configured, they are:

- EMAIL_HOST
- EMAIL_USERNAME
- EMAIL_PASSWORD
- EMAIL_PORT

Below is an example of how you might use pkg.

package main

import gse "github.com/jotonilima/gosendmail"
import "log" 


func main() {
 	email := gse.New()
 	if email == nil {
 		log.Println("Error New() check the required fields: 
		 EMAIL_HOST,EMAiL_USERNAME,EMAIL_PASSWORD,EMAIL_PORT")
 		return
 	}
 	m := gse.NewMessage("Title here", "Body message here.")
 	m.To = []string{"<to-email>@gmail.com"}
 	m.CC = []string{"<copy1-email>@gmail.com", "<copy2-email>@gmail.com"}
 	m.BCC = []string{"<bc-email>@gmail.com"}
 	m.AttachFile("/path/to/file1.pdf")
 	m.AttachFile("/path/to/file2.pdf")
 	if email.Send(m) != nil {
 		log.Println("Error when sending:", err.Error())
 		return
 	}
 	log.Println("Sent with success")
}

To run the code above:

$ export EMAIL_HOST="smtp.<YOUR-SERVER>.com"
$ export EMAIL_USERNAME="<USER>"
$ export EMAIL_PASSWORD="<PASSWORD>"
$ export EMAIL_PORT="587"
$ go mod init <your-pkg>
$ go mod tidy
$ go run main
Releases(v0.0.4)
Owner
Jefferson Otoni Lima
Senior Software Enginer and Architect entrepreneur since 2006, currently as Senior Software Enginer at Engineering Brasil and CEO & Co-Fundador S3WF
Jefferson Otoni Lima
:incoming_envelope: Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)

go-mail Lightweight email package with multi-provider support (ses, mandrill, postmark) Table of Contents Installation Documentation Examples & Tests

MrZ 36 Nov 8, 2021
VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients

VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients Email clients use different rendering standards. This is

Alexey Vasiliev 10 Dec 1, 2021
a simple api that sent spam via sms and email

a simple api that sent spam via sms and email routes: /sms /email example request with python

null 3 Oct 19, 2021
Lightweight SMTP client written in Go

Hectane Hectane is both a Go package providing an SMTP queue for sending emails and a standalone application that exposes this functionality via an HT

Hectane 209 Nov 17, 2021
Web and API based SMTP testing

MailHog Inspired by MailCatcher, easier to install. Download and run MailHog Configure your outgoing SMTP server View your outgoing email in a web UI

MailHog 9.3k Dec 5, 2021
MailHog SMTP Protocol

MailHog SMTP Protocol github.com/mailhog/smtp implements an SMTP server state machine. It attempts to encapsulate as much of the SMTP protocol (plus i

MailHog 65 Sep 24, 2021
Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Inbucket 886 Dec 3, 2021
golang honeypot smtp server

honeygogo-smtp standalone honeypot A lightweight SMTP honeypot server written in Go, leveraging go-smtp. A stand alone version of a module from honeyg

jothflee 0 Nov 11, 2021
Simple SMTP Server for Testing

go-smtptester Simple SMTP Server for Testing. How it works All received mails are saved in a sync.Map with a key: From+Recipient1+Recipient2 Mails to

null 1 Nov 18, 2021
Robust and flexible email library for Go

email Robust and flexible email library for Go Email for humans The email package is designed to be simple to use, but flexible enough so as not to be

Jordan Wright 1.9k Nov 28, 2021
:white_check_mark: A Go library for email verification without sending any emails.

email-verifier ✉️ A Go library for email verification without sending any emails. Features Email Address Validation: validates if a string contains a

AfterShip Ltd. 337 Dec 2, 2021
An email MIME artist for golang

Marcel is a tool to generate IETF compliant emails in raw MIME format. I mainly use this for generating emails with attachments and sending them via amazon SES. If that's what you're doing too, you may want notifications

David Banham 21 Sep 27, 2021
EMail Searcher By Golang

GiveMeMail ▄████ ██▓ ██▒ ██▓ ▓██████ ███▄ ▄███▓▓██████ ███▄ ▄███▓ ██ ██▓ ██▓ ██▒ ▀█▒ ▓██▒ ▓██░ █▒ ▓█ ▀ ▓██▒▀█▀ ██▒▓█

ConsT27 9 Oct 20, 2021
✉️ A Go library for email verification without sending any emails.

email-verifier ✉️ A Go library for email verification without sending any emails. Features Email Address Validation: validates if a string contains a

AfterShip Ltd. 248 Jun 24, 2021
End-to-end encrypted email for the mesh networking age

Yggmail It's email, but not as you know it. Introduction Yggmail is a single-binary all-in-one mail transfer agent which sends and receives email nati

Neil Alexander 56 Nov 15, 2021
Go implementation of the JWZ email threading algorithm

The JWZ Threading algorithm written in Go This is an open source Go implementation of the widely known JWZ message threading algorithm originally writ

GatherStars 14 Sep 30, 2021
📮 Simple (but useful) email sender written in pure Go v1.17. Support HTML templates and attachments.

?? Go Email Sender Simple (but useful) email sender written in pure Go v1.17. Yes, yet another email package here! ?? Support HTML templates and attac

Vic Shóstak 5 Nov 20, 2021
Monitoring and automation for Open Source email servers, starting with Postfix.

Welcome to Lightmeter Control Center, the Open Source mailops monitoring application.

Lightmeter 68 Nov 9, 2021
Experimental email attachment downloader for Kobo devices (gmail only ATM)

KoboMail Experimental email attachment downloader for Kobo devices (gmail only ATM) What is KoboMail? It is a software that will read emails sent to u

Carlos Lisboa 7 Nov 27, 2021