This guide helps to configure your Ruby On Rails application to send outgoing messages using your SMTP2GO account. We will be using Action Mailer, the part of the Rails library that allows to send emails from the application using mailer classes and views.
Please change the following in this script:
email@example.com: the sender’s email address.
USERNAME: your SMTP2GO username.
PASSWORD: your SMTP2GO password.
yourdomain.com: your domain name.
Create the Mailer called “UserMailer” with the action “sendMail” using following command:
Modify the “sendMail” action according to your requirement. Below is the example content of the/app/mailers/user_mailer.rb:
You may modify the text content of the message at /app/views/user_mailer/sendMail.text.erb. You may also create the HTML version of the message by creating /app/views/user_mailer/sendMail.html.erb file and add the required html content. Below is the example content of the text message:
Configure the SMTP settings in the development.rb or production.rb or test.rb configuration file according to your requirement. These files are located at /config/environments/ folder.
You may test the settings by running the following command from rails console.
Please note: as SMTP2GO allows a maximum of 20 concurrent SMTP connections, if you expect that your Ruby script could potentially make more than 20 concurrent SMTP connections, we recommend that you make use of a mail server such as Postfix, as an intermediary: http://www.smtp2go.com/docs/postfix/
You would then set your Ruby of Rails app to send emails via your Postfix mailserver, which would in turn route its emails through your SMTP2GO account.
Try SMTP2GO free for as long as you like:Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.