How To Test Sending Thousands Of Emails - ruby-on-rails

I'm developing an application that will send thousands of emails per day based on a CSV file using Amazon SES.
My client would like to send around 50,000 in one hit.
The app is almost done however i would like to test it with thousands of emails. What a shame would it be that on my first try with live data it doesn't work.
Right now i have only tested it using about 10 emails in my CSV file.
Does anyone know of a way to test sending around 10,000 emails? Obviously i can't use real data.

I believe you can use real data. To test 10,000 emails for example, you can do the following (assuming you've already increased your SES sending limits):
Generate 10,000 email recipients in your CSV file for a target domain that you already manage. Those 10,000 email addresses should be random and non-existent (e.g., 1eed1417-cc2c-4f7c-8ddb-7e0dfbcacb31#mydomain.com).
Configure a catch-all email address for mydomain.com (e.g., catch-all#mydomain.com) to receive emails sent to any non-existent address.
Add SES SMTP servers to mydomain.com's trusted senders/addresses and make sure your mailserver's throttling rules allow this sending volume.
Test during off-peak hours and check the inbox of your catch-all mailbox.

What i ended up doing is using https://mailtrap.io/
I made 25 emails. Then sent 600 emails to each of the 25 emails. That equals 15,000.
I didnt use action mailer to send the emails. I used the Amazon SES send email method
def send_email!
client.send_email(email_attributes)
end
private
def client
Aws::SES::Client.new(region: Rails.application.secrets.ses_region,
access_key_id: Rails.application.secrets.aws_access_key_id,
secret_access_key: Rails.application.secrets.aws_secret_access_key)
end
Used Kabana for tracking the emails. If they bounced, delivered and so on.
SES won't track email opens so we have a small Node-JS app that will track opens and clickable links.
The app sends around 15000 emails in 20minutes.

I am assuming you are not doing a full end-to-end test (which includes checking to ensure the email was received) but rather are just performing a functional test of your application logic.
If that is the case,
Point your application at a test email server and disable outbound email for all queues. You could also do this on a production server, at say 3:00 am, I guess, but be careful!
Run the application
Check the email server's outbox and count the number of items that have queued up.
If the count matches, your test has passed.
Don't forget to purge the queue before turning it back on!

Related

rails sending bulk mails

We are using Rails 2.3.8 version. In our application, we tend to send individual email to all users ( around 1500 users - Bulk email ). We are not using any services other than Actionmailer. Hence, we cannot use any service (like mailGun, sendGrid, mailchimp, etc) Also, we have our own SMTP server, through which all the mails are sent.
We have added our mailing functionality to be executed in two scenarios.
Rake Task with CRON JOB ( Auto mails to be sent at specific time)
Via controller ( Mails are sent when a button is clicked)
In both the cases, Initially, the mails are forwarded to the users without any issues. As the user count increases, suddenly the mail functionality stops and throws either of the two following errors.
535 5.7.3 Authentication Unsuccessful
Execution expired
Could anyone please help me sort out the issue?
Is there any timeout value that has to be set for SMTP server connectivity? Or are there any restrictions (like number of mails sent per minute) ?
Thanks in Advance

Mandrill is ghosting accounts or am i incorrect - it says delivered however mandrill did not even tried to send emails

I am using free mandrill account and sending email via using template and API
When i send message it returns okay it is sent as status
However even after several days there is still no smtp events at mandrill interface and the email is not arrived
So i am 100% suree mandrill is ghosting accounts
Or there is something else that i do not know?
Thank you for answers
PS: At the beginning emails were arriving but after some point no smtp events and no emails ever arrived even though no error message parsed. Also when i send to non existing email no bounce message returned.
Also account reputation is 61 : excellent
Yes i believe mandrill certainly ghosting accounts
After trying with several accounts i am now sure of it
Even if you send to non existing gmail email, it says delivered in its interface
However it should have displayed hard bounced
So beware of their free service. I believe this is not an ethical way of working. People would think that their emails are arriving however they are ghosted and mandrill did not even try to send them and yet displays delivered
Have you check it on Mandrill account? It shows all the report at outbound tag. The reason is, a queued response in the Mandrill API is not the same as a queued response from a recipient server.
When you send a message through Mandrill, you first relay it to Mandrill, Mandrill processes it, and then Mandrill relays it to the recipient server. This all happens quite quickly, but the two relaying steps are separate and distinct. The KB article you've linked to is providing additional details on that last step, relaying to recipient servers, not a queued status for the Mandrill API.
There are a number of reasons the Mandrill API may respond with queued including if you've added attachments or if you're sending to a bunch of recipients in a single API call.
Without seeing the actual API call that's being made, it's hard to say why you're getting a queued response. But if you're using the sample messages/send API call, you'll want to remove all of the optional parameters that you're not actually setting. For example, the sample has fake attachments, and a subaccount specified. The attachment will cause the call to be processed async. The subaccount probably doesn't exist, and would then cause the call to fail. So if that's the case, try removing all of those optional params. If not, please provide the API call you're making with sensitive data redacted (API key, actual email addresses).

Ruby on Rails app fetch bounces How to?

is there any possibility to check with the ActionMailer mail function if a mail-address is still alive?
My problem is that I have a ruby on rails application with lots of users, but some of those changed their mail address and now I got lots of mails back. It would be cool If I can check if the mail is still present, and if not I delete the user from Database.
Any Ideas for this problem?
If you're sending mail and it fails, you can view those if you've configured
raise_delivery_errors = true
That would go in your config/environment/development or production.rb
Sadly though, with raise_delivery_errors there's a gotcha:
This only works if the external email server is configured
for immediate delivery.
If you have the option to use something like mailchimp, sendgrid, etc it handles most of this for you - it won't send to bogus emails, it silences them on future mailings and is just a convenient way to manage your email clickthroughs, etc. Some email services give you a webhook that says "this email bounced" which you can then do something with in your app/database. Or more primitively, you can download a csv periodically from their portal and update the database.

Is there a way to setup a fake email inbox to check that email messages are being sent in ruby on rails?

I'm testing several user accounts and don't want to setup different emails to test with. All I need to know is if the email has been sent from my app successfully.
Is there a way to setup a fake email inbox to check that email messages are being sent in Ruby on Rails?
Set up MailCatcher:
MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to smtp://127.0.0.1:1025 instead of your default SMTP server, then check out http://127.0.0.1:1080 to see the mail that's arrived so far.
This does several useful things for you:
Not only can you see that email is being sent but you can look at the email (text and HTML parts) as well.
You won't have to worry about spamming anyone as all the email your application sends goes straight to MailCatcher.
You won't have to worry about setting up a bunch of real email accounts anywhere, MailCatcher doesn't care what the addresses are, it just grabs the email and shows it to you.
Most importantly, your application doesn't have to change to use it, you just set up the appropriate SMTP values and away you go. This means that you're not running different code paths for your email handling in development, testing, and production and that means fewer bugs and late night disaster calls.
During development and testing, emails are also shown on the console. That has always been enough for me – I don't doubt rails' ability to actually send it once it's in production.

Emails sent from postfix via a Rails app are getting sent to spam in gmail

When using 'mail' command to send email to a gmail user, the email goes through fine. When sending an email using a Rails app, the email is sent to the spam folder for the gmail user. Can someone help me think through this?
Emails landing in SPAM can happen due to many reasons:
Wrong Mail Server setup: Checkout here on how to setup
Email content: Content of the email can also invite SPAM. Sites like SpamCheck helps to check whether the content of the email is ok.
As mentioned by #Noli above, using services like Sendgrid, Critsend etc for sending out emails, chances of landing them in Inbox will be more. You can use them as relay servers from Postfix. But the first two steps are anyway necessary.
Use Mailchimp if you want to sent emails to many people, for eg: for sending out newsletters, marketing emails etc.
Mail deliverabillty is extraordinarily hard to get right. You should consider leaving this to the specialists like Sendgrid or Mailchimp, and not spend tooooo much development time thinking about it
Another thing to check is that if this is a new server, you may need to set up Domain Keys to authenticate to Gmail. This happend to me and I was able to get my mail removed from the spam folder by following these:
https://help.ubuntu.com/community/Postfix/DomainKeys
https://help.ubuntu.com/community/Postfix/DKIM

Resources