This gem contains methods for easily interacting with the Pepipost Email Sending API to send emails within few seconds.
We are trying to make our libraries a Community Driven. To help us building right things in proper order we would request you to help us by sharing comments, creating new issues or pull request.
This client library is a Ruby gem which can be compiled and used in your Ruby on Rails project. This library requires a few gems from the RubyGems repository.
Open the command line interface/terminal and navigate to the folder of your choice and run the below commands to download and navigate to the downloaded folder:
git clone https://github.com/pepipost/pepipost-sdk-ruby.git
cd pepipost-sdk-ruby
gem build pepipost.gemspec
to build the gem.
gem install pepipost-5.0.0.gem
to install pepipost gem
Once pepipost_gem is installed, use the sample example to send test email.
The following section explains how to use the Pepipost Gem in a new Rails project using RubyMine.
The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Starting a new project
Close any existing projects in RubyMine by selecting:
File -> Close Project
Create New Project
to create a new project from scratch.TestApp
as the project name.Rails Application
as the project type.OK
.In the next dialog make sure that correct Ruby SDK is being used (minimum 2.0.0)
OK
.This will create a new Rails Application project with an existing set of files and folder.
Add reference of the gem
Gemfile
in the Project Explorer window under the TestApp
project node.gem 'pepipost_gem', '~> 2.5.0'
Adding a new Rails Controller
TestApp
project is created.controllers
will be visible in the Project Explorer under the following path:
TestApp > app > controllers
. New -> Run Rails Generator
.controller
template.Hello
.Index
. OK
.HelloController
will be created in a file named hello_controller.rb
containing a method named Index
.require 'pepipost'
require 'json'
include Pepipost
api_key = 'Your api_key here'
client = PepipostClient.new(api_key: api_key)
mail_send_controller = client.mail_send
body = Send.new
body.from = From.new
body.from.email = 'hello@your-register-domain-with-pepipost'
body.from.name = 'Example Pepi'
body.subject = 'Emailing with Pepipost is easy'
body.content = []
body.content[0] = Content.new
body.content[0].type = TypeEnum::HTML
body.content[0].value = '<html><body>Hey,<br><br>Do you know integration is even simpler in Pepipost, <br>with Ruby <br> Happy Mailing ! <br><br>Pepipost </body></html>'
body.personalizations = []
body.personalizations[0] = Personalizations.new
body.personalizations[0].to = []
body.personalizations[0].to[0] = EmailStruct.new
body.personalizations[0].to[0].name = 'random-1'
body.personalizations[0].to[0].email = 'random-1@mydomain.name'
begin
result = mail_send_controller.create_generatethemailsendrequest(body)
puts (result)
rescue APIException => ex
puts "Caught APIException: #{ex.message}"
end
*Note :: Domains showing with Active status on Sending Domain dashboard are only allowed to send any sort of emails.* In case there are no Sending Domain added under your account, then first add the domain, get the DNS (SPF/DKIM) settings done and get it reviewed by our compliance team for approval. Once the domain is approved, it will be in ACTIVE status and will be ready to send any sort of emails.
ruby sendEmail.rb
v5.0 has been released! Please see the release notes for details.
All updates to this library are documented in our releases. For any queries, feel free to reach out us at dx@pepipost.com
If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.
pepipost-sdk-ruby library is guided and supported by the Pepipost Developer Experience Team . This pepipost gem is maintained and funded by Pepipost Ltd. The names and logos for pepipost gem are trademarks of Pepipost Ltd.
This code library was semi-automatically generated by APIMATIC v2.0 and licensed under The MIT License (MIT).