Mandrill "Send A Copy Of Every Email To This Address" : CC or BCC? - mandrill

On the 'Sending Defaults' settings page of mandrill, there is a setting 'Send A Copy Of Every Email To This Address' field.
I would like to know 2 things: Is this sent using 'to', 'CC' or 'BCC', and if I send to X users, do I receive X emails or just 1?
I assume 'BCC' and '1' are the answers, but mandrill's test suite doesnt actually send emails, so this function isn't triggered and I cannot find any documentation on this.

Related

AWS-SDK-SES: How Can I Check the Existence of an Email Address in Rails?

I currently have Rails applications that use SES to send emails. Unfortunately no matter how much code I put in my application I still get emails with invalid email addresses.
I want to use AWS to verify if I have a valid email address, meaning that the syntax is correct and does other verification like checking if the mailbox exists.
I installed the aws-sdk-rails gem in my application. I added my access_key_id and secret_access_key to config/credentials.yml.enc.
I added the following code from this awsdocs/aws-doc-sdk-examples GitHub repository to my contact form and made minor changes.
require 'aws-sdk-ses'
# Replace recipient#example.com with a "To" address.
recipient = params[:email]
error = " "
# Create a new SES resource in the us-west-2 region.
# Replace us-west-2 with the AWS Region you're using for Amazon SES.
ses = Aws::SES::Client.new(region: 'us-west-2')
# Try to verify email address.
begin
ses.verify_email_identity({
email_address: recipient
})
puts 'Email sent to ' + recipient
# If something goes wrong, display an error message.
rescue Aws::SES::Errors::ServiceError => error
puts "Email not sent. Error message: #{error}"
end
I entered an email address that AWS SES said that the mailbox didn't exist this morning. However when I ran this code it didn't produce an error as I thought it might. When I checked the Rails debug log error was blank. The region in my code is the one that I use to successfully send transactional emails from all my websites.
I couldn't find any documentation about that code that says how much verification it does for the email address.
Can I use this gem to find if email addresses exist or have other problems like SES checks when an email has a To: email address?

The application goes offline when trying to send more than thousands of emails in Rails with AWS SES

I have implemented a platform using rails, and the goal is to send thousands of emails to customers with one click. The concept is that an email array runs each loop and inside each loop runs send email functionality like below.
#emails = ['abc#gmai.com', 'abc#example.com'] # More than 3 thousands
#emails.each do |email|
aws_email_sender(email, #email_subject, #email_body_html)
end
And the email function is like below:
def aws_email_sender(recipient, subject, htmlbody)
sender = "hello#example.com"
awsregion = "ap-west-1"
# The HTML body of the email.
htmlbodycontent = "#{htmlbody}"
# The email body for recipients with non-HTML email clients.
textbody = "This email was sent with Amazon SES using the AWS SDK for Ruby."
# Specify the text encoding scheme.
encoding = "UTF-8"
# Create a new SES resource and specify a region
ses = Aws::SES::Client.new(region: awsregion)
# Try to send the email.
begin
# Provide the contents of the email.
resp = ses.send_email({
destination: {
to_addresses: [recipient]
},
message: {
body: {
html: {
charset: encoding,
data: htmlbodycontent
},
text: {
charset: encoding,
data: textbody,
},
},
subject: {
charset: encoding,
data: subject,
},
},
source: sender,
});
# If something goes wrong, display an error message.
rescue Aws::SES::Errors::ServiceError => error
puts "Email not sent. Error message: #{error}"
end
end
The email is sending well by AWS but my rails application has gone down like
A timeout occurred, error code 524
I couldn't get the breaking point, why has my application gone down every time?
Thanks in Advance
If 524 is an HTTP status code then it means...
Cloudflare was able to make a TCP connection to the website behind them, but it did not reply with an HTTP response before the connection timed out.
Meaning your Rails app is behind a Cloudflare proxy. Cloudflare received an HTTP request, forwarded it to your app, waited around for your app to respond, but your app never did. A more detailed explanation can be found here.
Probably because it's trying to send emails to 3000 people one-by-one.
There's two strategies to fix this.
Use Bulk Email
Since the content of the email is the same for everyone, use an email template to send bulk email using the #send_bulk_templated_email method.
You can send to up to 50 addresses at a time, so use #each_slice to loop through emails in slices of 50.
This will be more efficient, but your app will still be waiting around for 3000/50 = 60 AWS API calls. At worst it will still time out. At best the user will be waiting around for a form submission.
Use A Background Job
Anytime your app needs to do something that might take a lot of time, like using a service or a large database query, consider putting it into a background job. The Rails app queues up a job to send the emails, and then it can respond to the web request while the mailing is handled in the background. This has other advantages: errors calling the service won't cause an error for the user, and failed jobs due to a temporary service outage can automatically be retried.
In Rails this is done with ActiveJob and you could write a job class to send your mail.
Use ActionMailer
However, Rails also offers a class specifically for sending email in the background: ActionMailer. You can have ActionMailer use AWS with the aws-sdk-rails gem.
config.action_mailer.delivery_method = :ses

imapclient.IMAPClient [Seen] Flag in Python

I am processing emails using imapclient.IMAPClient in Python and want to flag the successfully processed emails as "Seen" at the end. I have tried different ways but they either do not flag all the successful email or do not show as "read" in my Gmail inbox. I am looking for a way to update Gmail inbox flags of successfully processed emails using IMAP.
Here is the summary of code that I've tried:
imapObj = imapclient.IMAPClient(self.server_host, ssl=True)
imapObj.login(self.user_name, self.password)
imapObj.select_folder(email_folder, readonly=False)
#searches unseen emails with subject containing document
self.emails = imapObj.search(
[search_criterion1, search_value1,
search_criterion2, search_value2,
search_criterion3, search_value3,
search_flag])
#using PEEK to not mark all the emails as [Seen]
self.raw_messages = imapObj.fetch(self.emails, 'BODY.PEEK[]')
self.successful_emails = []
for i, self.email_id in enumerate(self.emails):
...do some process and for each successful process, append the email_id to list...
self.successful_emails.append(self.email_id)
#flag the successfully processed email as [SEEN]
imapObj.set_flags(self.successful_emails, '+FLAGS', '\SEEN')

How to add more than 1000 email address using mail_to

Currently i have the below code in index view
<div id = "GetEmails"><%= mail_to "xyz#gmail.com" do %><strong>Send Mail</strong><% end %></div>
In runtime, I am updating the value of mailto: which consists of more than 1000
+email address
Now, when I click on "Send Mail", outlook is not getting opened by copying all the email address in To: field
But, if the number of email address are < 100, the on click of "Send Mail" I am able to copy all the email address in To: filed
Manually, I am able to copy more than 3000 email address.
How do I get copy all the email address in To line by clicking "Send Mail".
The mailto:(as any other URL) has a character limit for the URL, it's vary from browser to browser, or from E-Mail client to E-Mail client.
Please try to use JS.
You could have a HTML element with data attribute where all emails would be stored and then try this:
<div id="my-mails-storing-element-id" data-mails="person1#domain.com, person2#domain.com,person3#domain.com"></div>
var mailsDom = document.getElementById("my-mails-storing-element-id")
location.href = mailto:mailsDom.dataset.mails;
But it would be better if you create separate action in your controller to get those emails. Then you just need to make AJAX call to get mails data.
I hope it'd help you. Please let me now if it worked (I've tried with Mailspring mail client and it worked)

'Confirmation token is invalid' when testing with Cucumber

I'm trying to get a sign up form working with Devise; I'm testing it with Cucumber.
When a user signs up, I send a confirmation e-mail. Something goes wrong when running my test, though.
This is my scenario:
Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| user#ticketee.com | password | true |
And "user#ticketee.com" opens the email with subject "Confirmation instructions"
And they click the first link in the email
Then I should see "Your account was successfully confirmed."
And I should see "Signed in as user#ticketee.com"
However, I get the following error:
expected there to be content "Your account was successfully confirmed. You are now signed in." in "\n Ticketee\n \n\nTicketee\nSign up\n Sign in\nResend confirmation instructions\n\n\n \n 1 error prohibited this user from being saved:\n Confirmation token is invalid\n\n\n Email\n\n \n\n Sign inSign upForgot your password?" (RSpec::Expectations::ExpectationNotMetError)
I guess the important part here is:
1 error prohibited this user from being saved:\n Confirmation token is invalid
I have tested this manually (went to sign up and clicked the confirmation link in the e-mail) and this works fine.. It's only when I test through Cucumber that I get the 'Confirmation token is invalid' message. Anyone know how I can fix this? I'd like to see my tests pass..
Thanks a lot.
EDIT: Steps asked for in the comments:
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
open_email(address, :with_subject => subject)
end
Clicking link:
When /^(?:I|they) click the first link in the email$/ do
click_first_link_in_email
end
I just looked at the confirmation email I got and my e-mail address is parsed as a mailto: link; I changed the first link step to this:
And they follow "Confirm my account" in the email
but that didn't work either.. I'm still getting the invalid token error message.
So.. I wasted two hours on this. I had a typo.
I have the following line:
unconfirmed = attributes.delete("unconfirmed") == "true"
I forgot to put the quotes around true. Without the quotes, the test passes..
Jeez.
Thanks to everyone who put some time in helping me :)

Resources