Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I work with/around Gmail's SMTP outbound sending limits?
    primarykey
    data
    text
    <p>I'm using my Gmail Apps for Domain account to send email within my rails application for standard automated emails (user signup, forgot password, notify admin of new comment, etc), but I'm worried about the 500 emails per day limit set by Google. </p> <p>Google suggests one way to overcome the limit is to use multiple user accounts. </p> <p>So, I've setup 10 additional gmail user accounts (noreply1, noreply2, noreply3, etc) - I'd like to track when any of these accounts has sent 500 emails in a 24 hour period and use the idle account accordingly. </p> <p>How do I dynamically set the <code>:user_name</code> value in <code>ActionMailer::Base.smtp_settings</code>?</p> <p>Here's my current setup - NOTE: this sends from "noreply1" every time, even though i'm explicitly setting :user_name and :from to "noreply2":</p> <pre><code>--- development.rb --- ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address =&gt; "smtp.gmail.com", :port =&gt; "587", :domain =&gt; "mydomain.com", :authentication =&gt; :plain, :user_name =&gt; "noreply1@mydomain.com", :password =&gt; "password" } --- account.rb --- (MODEL, called via a callback) after_create :send_welcome_email ... def send_welcome_email #ActionMailer::Base.smtp_settings[:user_name] = 'noreply2@mydomain.com' ActionMailer::Base.smtp_settings.merge!({:user_name =&gt; "noreply2@mydomain.com"}) SubscriptionNotifier.deliver_welcome(self) end --- subscription_notifier.rb --- (MODEL) class SubscriptionNotifier &lt; ActionMailer::Base def welcome(account) @sent_on = Time.now @subject = "Welcome to the App" @recipients = account.email @from = "noreply2@mydomain.com" @body = { :account =&gt; account } end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload