Class: Sendgrid::Web::Mail
Instance Method Summary collapse
Methods inherited from Client
base_uri, config, #config, configure
Instance Method Details
#send(to: nil, to_name: nil, x_smtpapi: nil, subject: nil, text: nil, html: nil, from: nil, bcc: nil, from_name: nil, reply_to: nil, date: nil, files: nil, content: nil, headers: nil) ⇒ Sendgrid::Web::Response
Note:
The required parameters are: from, text/html, subject and to.
Send an email.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/sendgrid/web/mail.rb', line 35 def send( to: nil, to_name: nil, x_smtpapi: nil, subject: nil, text: nil, html: nil, from: nil, bcc: nil, from_name: nil, reply_to: nil, date: nil, files: nil, content: nil, headers: nil) = { 'to' => to, 'toname' => to_name, 'x-smtpapi' => x_smtpapi, 'subject' => subject, 'text' => text, 'html' => html, 'from' => from, 'bcc' => bcc, 'fromname' => from_name, 'replyto' => reply_to, 'date' => date, 'files' => files, 'content' => content, 'headers' => headers } %w{ subject to }.each do |required_option| if [required_option].nil? raise ArgumentError.new( "Missing required `#{required_option}` option") end end if ['text'].nil? && ['html'].nil? raise ArgumentError.new( 'Missing required `text` or `html` option') end res = connection.post( '/api/mail.send.json', default_params()) craft_response(res) end |