Skip to content

Latest commit

 

History

History
44 lines (37 loc) · 1.38 KB

File metadata and controls

44 lines (37 loc) · 1.38 KB
layout page
weight 0
title Ruby
navigation
show
true

{% github sendgrid/sendgrid-ruby#usage PHP %} We recommend using SendGrid Ruby, our client library, available on Github, with full documentation. {% endgithub %}

This example shows how to send email plain text and HTML email using Ruby. The gem Mail is required.

{% codeblock lang:ruby %} require 'mail' Mail.defaults do delivery_method :smtp, { :address => "smtp.sendgrid.net", :port => 587, :domain => "yourdomain.com", :user_name => "yourusername@domain.com", :password => "yourPassword", :authentication => 'plain', :enable_starttls_auto => true } end

mail = Mail.deliver do to 'yourRecipient@domain.com' from 'Your Name name@domain.com' subject 'This is the subject of your email' text_part do body 'Hello world in text' end html_part do content_type 'text/html; charset=UTF-8' body 'Hello world in HTML' end end {% endcodeblock %}

To install the Mail gem please note that you need the OpenSSL library installed, then run the following:

{% codeblock lang:bash %} gem install mail {% endcodeblock %}