Send Email Using Golang
Simply copy & paste the libraries below into your application to start sending!
See Golang Code SamplesVisit GitHub Basic Message
A basic message is an email message like you’d send from a personal email client such as Outlook. A basic message can have many recipients, including multiple, To Addresses, CC Addresses, and even BCC Addresses. You can also send a file attachment in a basic message.
import ( "github.com/socketlabs/socketlabs-go/injectionapi" "github.com/socketlabs/socketlabs-go/injectionapi/message" ) func main() { client := injectionapi.CreateClient(000001, "YOUR-API-KEY") basic := message.BasicMessage{} basic.Subject = "Sending a Basic Message" basic.HtmlBody = "<html>This is the Html Body of my message.</html>" basic.PlainTextBody = "This is the Plain Text Body of my message." basic.From = message.EmailAddress{EmailAddress: "[email protected]"} basic.ReplyTo = message.EmailAddress{EmailAddress: "[email protected]"} //A basic message supports up to 50 recipients and supports several different ways to add recipients basic.AddToEmailAddress("[email protected]") //Add a To address by passing the email address basic.AddCcEmailAddress("[email protected]") //Add a CC address by passing the email address and a friendly name basic.AddBccEmailAddress("[email protected]") //Add a BCC address by passing the email address //Send the message _, _ = client.SendBasic(&basic) }
Bulk Message
A bulk message usually contains a single recipient per message and is generally used to send the same content to many recipients, optionally customizing the message via the use of MergeData.
import ( "github.com/socketlabs/socketlabs-go/injectionapi" "github.com/socketlabs/socketlabs-go/injectionapi/message" ) func main() { client := injectionapi.CreateClient(000001, "YOUR-API-KEY") //Build the message bulk := message.BulkMessage{} bulk.Subject = "Sending A Bulk Message" bulk.HtmlBody = "<html>This is the Html Body of my message sent to the recipient with %%EyeColor%% eyes.</html>"; bulk.PlainTextBody = "This is the Plain Text Body of my message sent to the recipient with %%EyeColor%% eyes."; bulk.From = message.EmailAddress{EmailAddress: "[email protected]"} bulk.ReplyTo = message.EmailAddress{EmailAddress: "[email protected]"} //Add Bulk Recipients recipient1 := bulk.AddToFriendlyBulkRecipient("[email protected]", "Recipient #1") recipient1.AddMergeData("EyeColor", "Green") recipient2 := bulk.AddToFriendlyBulkRecipient("[email protected]", "Recipient #2") recipient2.AddMergeData("EyeColor", "Blue") //Send the message _, _ = client.SendBulk(&bulk) }
How to Get Started
I don’t have a SocketLabs Account
Create Your Account
I have a SocketLabs account
Get Your API Key & Server ID
About our Code Libraries
SocketLabs’ email API plays well with your favorite platforms and development frameworks, including .NET, PHP, Java, Node.js, Python, Go, and more! As a developer, our APIs for sending email give you all the tools you need to embed powerful email functionality into your applications.
You’re in Good Company







We’re Always Here For You
Have questions or need help? Here’s how to reach support:
SocketLabs Developers
SocketLabs is Built for Developers, By Developers
Reach the Inbox With Industry-Leading Deliverability
Integrate with Your Application in Minutes