Recommendations for a contact function using an existing icloud email

Hello,

I’m currently working on a website with a contact function and I would like to program that function to link to my icloud email address to send me any emails created through it. But I am not sure on how to fully link the two sources. What are some of your recommendations for using Rails to link to an icloud email account? I have already made a contact function utilizing Mailcatcher for it, but I believe I can do better with something like that.

Are you looking to have contact messages mailed to your address after they are created on your Rails site? Have a read of the ActionMailer integration, in that case. You will need to set up an SMTP service, either on your server, or more reliably, on a paid or free-tier SMTP-as-a-service provider like SendGrid or similar. Then it’s just a matter of creating a mailer and configuring the service.

In one simple app, I made the following model to handle this, since I didn’t care to save these to the database. They’re just mailed on to me if they pass validation.

class Contact
  include ActiveModel::Model
  attr_accessor :name, :email, :message

  # bunch of validations here...
end

I have two different mailers, one to send a thanks message back to the sender, and another to send me the contact.

I set up a ContactController and used the #create method to process the form requests:

  def create
    @contact = Contact.new contact_params
    if @contact.valid?
      NotificationMailer.contact(@contact).deliver_now if @contact.valid?(:notification)
      ThanksMailer.contact(@contact).deliver_now if @contact.valid?(:thanks)
      render :thanks
    else
      render :new
    end
  end

I use two different mailers, and validate them separately, because I reply more often than I actually care to see the contents of the message. (If you send a reply to a spammer, they feel like their job is done, and don’t try harder to get around my rudimentary filters.)

Your question, though, said that you want to link to your e-mail account. Do you mean being able to see any messages in that mailbox? That sounds like you want to investigate an IMAP client library for Rails.

Walter

Thank you. I’ll look more into this!