Skip to content

Instantly share code, notes, and snippets.

@Workman
Last active August 29, 2022 18:52
Show Gist options
  • Save Workman/699a83bc414d0a8ff13dce30065d78af to your computer and use it in GitHub Desktop.
Save Workman/699a83bc414d0a8ff13dce30065d78af to your computer and use it in GitHub Desktop.
For raw ruby
# Prerequisite: `gem install socketlabs-injectionapi`
# Tested in Ruby 2.7.0
require "socketlabs-injectionapi"
require "json"
include SocketLabs::InjectionApi
include SocketLabs::InjectionApi::Message
serverId = 123456
injectionApiKey = "YourApiKey"
verifiedDomain = "YourDomain.com"
client = SocketLabsClient.new(serverId.to_s, injectionApiKey)
message = BasicMessage.new
message.subject = "Sending A Test Message"
message.html_body = "<html>This is the Html Body of my message.</html>"
message.plain_text_body = "This is the Plain Text Body of my message."
message.from_email_address = EmailAddress.new("no-reply@#{verifiedDomain}")
message.add_to_email_address(EmailAddress.new("server#{serverId}@api-welcome.socketlabs.com"))
response = client.send(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment