A
A
Antony Ryabov2015-03-02 17:16:27
ruby
Antony Ryabov, 2015-03-02 17:16:27

How to hide mailbox access when using mail in ruby?

There is a script that sends the result of the work to the mail via SMTP using gem mail. I want to put the script in a public repository, but I don't want to burn access to the mail. What is the best way to move the submit options to a separate file to add it to .gitignore?
I send like this:

options = { :address              => "smtp.gmail.com",
            :port                 => 587,
            :domain               => 'domain.com',
            :user_name            => '[email protected]',
            :password             => 'mail_password',
            :authentication       => 'plain',
            :enable_starttls_auto => true  }

Mail.defaults do
  delivery_method :smtp, options
end

#Sending
Mail.deliver do
  from     '[email protected]'
  to        '[email protected]'
  subject  'some subject'
  html_part do
    content_type 'text/html; charset=UTF-8'
    body     "#{html_mail}"
  end
end

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vsuhachev, 2015-03-02
@tonymadbrain

Ruby usually uses yaml to store configs. Read/write in this format is in the standard Ruby library

E
Eugene Burmakin, 2015-03-02
@Freika

The figaro gem should work. Move the options to environment variables and you'll be happy :)

T
therhino, 2015-03-02
@therhino

Rails 4.1 introduced a file called secrets.yml to store this stuff. If the version is less, then really in a separate .yml file and it in .gitignore.
Another good gem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question