title: How to send an email on Rails
body: <p>I'm trying to add a simple email form in my app, so I can receive emails from the users. I've followed some tutorials and I end up to succeed to send emails to my self in development mode. This is how I did it:</p>
  
  <p>1) I installed this gem: 'mail_form';</p>
  
  <p>2) Generated a contact controller:</p>
  
  <pre><code>#contacts_controller.rb
  
  class ContactsController &lt; ApplicationController
    def new
      @contact = Contact.new
    end
  
    def create
      @contact = Contact.new(params[:contact])
      @contact.request = request
      if @contact.deliver
        flash.now[:error] = nil
      else
        flash.now[:error] = 'Não foi possível enviar o email.'
      end
      redirect_back(fallback_location: vehicles_path)
    end
  end
  </code></pre>
  
  <p>3) I created (manually) a contact model:</p>
  
  <pre><code>#contact.rb
  
  class Contact &lt; MailForm::Base
    attribute :name,      :validate =&gt; true
    attribute :email,     :validate =&gt; /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
    attribute :subject
    attribute :message, :validate =&gt; true
    attribute :nickname,  :captcha  =&gt; true
  
    def headers
      {
        :subject =&gt; %("#{subject}"),
        :to =&gt; "myEmail@gmail.com",
        :from =&gt; %("#{name}" &lt;#{email}&gt;)
      }
    end
  end
  </code></pre>
  
  <p>4) Edited my development.rb</p>
  
  <pre><code>config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'gmail.com',
    user_name:            'myusername@gmail.com',
    password:             Rails.application.credentials.email_password,
    authentication:       :plain,
    enable_starttls_auto: true
  }
  </code></pre>
  
  <p>5) My form</p>
  
  <pre><code>&lt;%= form_with model:contact do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label "Name" %&gt;
      &lt;%= f.text_field :name, required: true %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label "Email" %&gt;
      &lt;%= f.email_field :email, required: true %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label "Subject" %&gt;
      &lt;%= f.text_field :subject, required: true %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label "Message" %&gt;
      &lt;%= f.text_area :message, as: :text, rows: 8, required: true %&gt;
    &lt;/div&gt;
  
    &lt;div class="hidden"&gt;
      &lt;%= f.email_field :nickname, hint: 'leave this field empty' %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= f.submit "Submit", class: "contact_submit" %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This worked well in development. </p>
  
  <p>Now, however, I don't know what to do in production. I already have my app hosted in DigitalOcean with the one-click Apps, which it comes with Postfix already installed. I don't know if I really need Postfix or not, or if I need a service like SendGrid or MailGun, or both. </p>
  
  <p>So to conclude this, I would like some information about what kind of services do I really need. Thank you!</p>