There is such a form in which you can write your thoughts and send them to the email address of the company:

<form id="contact-form"> <p></p> <p></p> <p></p> <p>Dear NATURA team,</p> <p>My <label for="your-name">name</label> is <input type="text" name="your-name" id="your-name" minlength="3" placeholder="(your name here)" required> and</p> <p>my <label for="email">email address</label> is <input type="email" name="your-email" id="email" placeholder="(your email address)" required> </p> <p> I have a <label for="your-message">message</label> for you,</p> <p> <textarea name="your-message" id="your-message" placeholder="(your msg here)" class="expanding" required></textarea> </p> <p> <button type="submit"> <svg version="1.1" class="send-icn" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" height="36px" viewBox="0 0 100 36" enable-background="new 0 0 100 36" xml:space="preserve"> <path d="M100,0L100,0 M23.8,7.1L100,0L40.9,36l-4.7-7.5L22,34.8l-4-11L0,30.5L16.4,8.7l5.4,15L23,7L23.8,7.1z M16.8,20.4l-1.5-4.3 l-5.1,6.7L16.8,20.4z M34.4,25.4l-8.1-13.1L25,29.6L34.4,25.4z M35.2,13.2l8.1,13.1L70,9.9L35.2,13.2z" /> </svg> <small>send</small> </button> </p> </form> 

I do not understand where it is necessary to insert the address of the company in order to send the letter. Thank you in advance!

    1 answer 1

    Well, since this is Rails, you probably want to use ActionMailer (guide) .

    To send a letter, you need to make an endpoint that will take form and send a letter:

    • Make a mailer class that will deal with sending letters. Customize to your taste. The address to which the letter will be sent can be indicated in a number of ways: in the declaration of the mailer class (the parameter to ), or in the code that uses it.
    • Make or select an existing controller in which to place the action that will send the letter.
    • To register in routes.rb , by what path and with which method (I suppose POST ) the form will go away and what action will be called up (described above).
    • Obviously, the same way and method specify the form.

    This is as accepted in Rails. You can make the decision a little easier (at the first point) if you give up ActionMailer and use just the gem mail right in the controller. How to indicate in it the address of the recipient, you can learn from the section Usage .