Socket
Book a DemoInstallSign in
Socket

smtpcom-sendapi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtpcom-sendapi

1.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

SMTP.com Sendapi

Website: https://www.smtp.com/solutions/transactional-email-service-api/ API documentation: https://www.smtp.com/wp-content/uploads/SMTP-Transactional-API-Documentation.pdf

Requirements

Ruby 1.9.3 or above

Installation

gem install smtpcom-sendapi

Bundler

source 'https://rubygems.org'

gem 'smtpcom-sendapi', require: 'smtpcom/sendapi'

Usage

Setting your API key

Smtpcom::Sendapi.api_key = 'YOUR_API_KEY'

Campaigns

List all

 Smtpcom::Sendapi::Campaign.all

Create

campaign = Smtpcom::Sendapi::Campaign.new
campaign.name = 'MyCampaign'
campaign.save

puts campaign.id
#=> 556998d4130e7f0aa881b5c1

Find

campaign = Smtpcom::Sendapi::Campaign.find('556998d4130e7f0aa881b5c1')

# you can also get some stats from campaign object
puts campaign.opens
puts campaign.clicks
puts campaign.delivered
puts campaign.bounced

Delete

campaign.delete

Email

email = Smtpcom::Sendapi::Email.new

email.subject   = 'Hello world subj'
email.from      = 'from@mywebsite.com'
email.body_text = 'Hello world'

# add recipients
email.add_recipient 'john@mywebsite.com', 'John'
email.add_recipient 'linda@mywebsite.com'

# add headers
email.add_header 'X-CustomID', '81d4350b'

# add attachment
# can be attachment data in base64 format, or a url where the attachment can be downloaded from
email.add_attachment 'Image1', 'image/jpeg', base64_content

# send email
email.send

Allowed email attributes:

- subject
- body_html
- body_text
- template_id
- from
- from_name
- reply_to
- reply_to_name
- return_path
- recipients
- recipients_url
- default_recipient_data
- attachments
- campaign
- utm_codes
- email_headers

Templates

List all

Smtpcom::Sendapi::Template.all

Create

template = Smtpcom::Sendapi::Template.new
template.name = 'Template 1'
template.from = 'john@mywebsite.com'
template.from_name = 'John'
template.subject = 'Hello world'
template.html = 'HTML email body'
template.save

puts template.id
#=> 156928d1130a7f0ab781b5c2

Find

template = Smtpcom::Sendapi::Template.find '156928d1130a7f0ab781b5c2'

Delete

template.delete

Senders

List all

Smtpcom::Sendapi::Sender.all

Reporting

Sends Report

# Parametes: time_start, time_finish, sender, campaign_id
report = Smtpcom::Sendapi::SendsReport.new time_start, time_finish

# return sends as array, accepts 2 optional parameters - count, page
report.all

# return failed sends as array, accepts 2 optional parameters - count, page
report.failed

Opens

# Parametes: time_start, time_finish, sender, campaign_id
report = Smtpcom::Sendapi::OpensReport.new time_start, time_finish

# return opens as array, accepts 2 optional parameters - count, page
report.all

# return opens as csv
report.csv

Clicks

# Parametes: time_start, time_finish, sender, campaign_id, url
report = Smtpcom::Sendapi::ClicksReport.new time_start, time_finish

# return clicks as array, accepts 2 optional parameters - count, page
report.all

# return clicks as csv
report.csv

Stats Summary

# Parametes: time_start, time_finish, sender, campaign_id, url
report = Smtpcom::Sendapi::StatsSummary.new time_start, time_finish

report.all

# in csv format
report.csv

Real Time Reporting

# get real time reporting settings
Smtpcom::Sendapi::RealTimeReporting.settings

# configure real time reporting
r = new Smtpcom::Sendapi::RealTimeReporting

r.queue_name            = 'MyQueue'
r.server_region         = 'us-west-2'
r.public_access_key     = 'public_key'
r.private_access_key    = 'private_key'
r.notify_opens          = false
r.notify_clicks         = true
r.notify_delivert_info  = false

r.save

FAQs

Package last updated on 20 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.