I'm Drew Blas. A software & cloud/devops engineer. I hold multiple AWS certifications, plus Kubernetes CKA & CKAD.
I love learning, helping others, and having fun with my teammates!
Pronouns: he/him
Provides an easy ruby DSL & interface to AWS SES
License: MIT License
When using the deliver! method (with a bang), The mail gem throws a "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]"
This is because the delivery_method used by action mailer (This is a AWS::SES::Base instance) tries to do this:
def deliver!
response = delivery_method.deliver!(self)
inform_observers
delivery_method.settings[:return_response] ? response : self
end
And because the delivery_method.settings is nil, it returns the error when trying to access the array. Maybe the AWS::SES::Base settings accessor should be initialized with an empty array.
Here's the gist of the problem - I'm using ActionMailer, and I'm trying to send an e-mail for which there is no e-mail view... thus there's no body text. I am trying to include an attachment. When I try to do this, I get the following error:
AWS::SES::ResponseError: InvalidParameterValueMissing start boundary
There's an easy workaround (if you ended up here via google!) - I just made empty views and all went well, but the somewhat cryptic error message had me scratching my head for a bit.
BTW - sending attachments w/out body text worked fine without the workaround before I started using SES (i.e., with standard SMTP ActionMailer).
I looked briefly into fixing this myself, but I wasn't sure the best way to do it. :( Maybe setting default blank message around line 100 of lib/aws/ses/send_email.rb ? That seemed a bit hokey, though. :S
Thank you!
Apologies in advance if I am doing something stupid.
I am trying to use aws-ses in a Rails 2.3.5 app using Ruby 1.8.7.
In my environment.rb I put
config.gem "aws-ses"
config.after_initialize do
ActionMailer::Base.delivery_method = :amazon_ses
ActionMailer::Base.custom_amazon_ses_mailer = AWS::SES::Base.new(:secret_access_key => 'XXX',
:access_key_id => 'xxx')
end
Where I get an error saying: activate': undefined method
map' for nil:NilClass (NoMethodError)
This is the complete stacktrace - was wondering if anyone else has hit something similar
Hi,
Are there any specific configurations needs to be done in order to send the emails asynchronously using DelayedJob?
I did the setup exactly as described in the readme, but I noticed that all emails sent using delayed_job did not go through SES while all synchronous emails did go through SES,
Thanks,
Roy
I got an exception message that says AWS::SES::ResponseError: MessageRejectedAddress blacklisted.
which should actually have some space between MessageRejected and Address. It is confusing because we tend to google MessageRejectedAddress.
In lib/aws/ses/response.rb:101, ResponseError#message has the following code:
def message
@response.error['Code'] + @response.error['Message']
end
but I think it should be something like:
def message
[ @response.error['Code'], @response.error['Message'] ].join(' - ')
end
for better error readability / googlability.
Hi, I had aws-ses 0.5.0 installed via Rubygems--now it looks like maybe you deleted it off the Rubygems repo and we're back to v0.4.4?
I'm trying to deliver mail through Rails 3 Action Mailer with:
mail :to => "[email protected]",
:bcc => ['[email protected]', '[email protected]'],
:subject => 'Blah'
The mail only gets sent to the :to address, the :bcc list is ignored. I believe the destinations are being reconstructed by Amazon as send_raw_email in lib/aws/ses/send_email.rb doesn't extract anything from the Mail object apart from the encoded message. It need something like this (but better, I just wrote this here and haven't tested it) to replace the current destinations code:
destinations = []
if args[:destinations]
destinations.concat args[:destinations].to_a
elsif args[:to]
destinations.concat args[:to].to_a
else
destinations.concat mail.to.to_a
destinations.concat mail.cc.to_a
destinations.concat mail.bcc.to_a
end
add_array_to_hash!(package, 'Destinations', destinations) if destinations.length > 0
I seem to be getting a strange error when going through the steps to install this. I went through the initial steps in irb and the new method creates the object just fine, but when I call ses.addresses.list.result, I get AWS::SES::ResponseError: AWS::SES Response Error: InvalidClientTokenIdThe security token included in the request is invalid
Any thoughts/ideas? I would greatly appreciate it!!!
EC2 roles are a much easier method for providing credentials.
Any chance there can be a shift to supporting them, otherwise I'll have to stay with the use of AWS::SimpleEmailService.
jeweler fetches dependenices from the Gemfile, so you do not need to add them in the Rakefile (remove the add_dependency statements) currently all dependencies are duplicated in the gemspec
https://github.com/drewblas/aws-ses/blob/master/aws-ses.gemspec#L86
When I try to send an email with a request like the following, my source gets replaced from "John Doe [email protected]" to "FooBar Smith", no matter to what I change my source. The means my email-client displays "FooBar Smith" as the actual sender-text. Any ideas on the misbehaviour?
Code:
ses.send_email(:to => ['[email protected]'], :source => '"John Doe [email protected]"', :subject => 'test', :text_body => 'Test 111222333')
./email.sh: line 8: Tue, 24 Dec 2019 20:31:17 +0500: command not found
subject: CN=email.us-east-1.amazonaws.com
start date: 2019-10-16 00:00:00 GMT
expire date: 2020-09-18 12:00:00 GMT
subjectAltName: email.us-east-1.amazonaws.com matched
issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
SSL certificate verify ok.
POST / HTTP/1.1
User-Agent: curl/7.35.0
Host: email.us-east-1.amazonaws.com
Accept: /
X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=, Algorithm=HmacSHA256, Signature=thNnmggU2ex3L5XXeMNfxf8Wl8STcVZTxscSFEKSxa0=
Content-Length: 266
Content-Type: application/x-www-form-urlencoded
MissingParameter
Either Date or x-amz-date header must be specified in the request
10bef69d-7aa0-4d9b-96a8-9e728d1ee46d
* Connection #0 to host email.us-east-1.amazonaws.com left intacti get undefined method `custom_amazon_ses_mailer=' for ActionMailer::Base:Class (NoMethodError)
i've set up my config/environments/production.rb
config.after_initialize do
ActionMailer::Base.delivery_method = :amazon_ses
ActionMailer::Base.custom_amazon_ses_mailer = AWS::SES::Base.new(
:access_key_id => 'my aws key',
:secret_access_key => 'my aws secret'
)
end
I tested on irb and its working fine
I tried to send a mail from the rails console, but although I verified my addresses and got 'OK' as a result, ses.addresses.list.result returns an empty array...
There is a broken require reference in the Rakefile at line 68:
https://github.com/drewblas/aws-ses/blob/master/Rakefile#L68
Hi,
Do you support sending email with attachments?
Do you have a code example?
Thanks,
Yuval
I have the following in my environments/development.rb:
config.after_initialize do
ActionMailer::Base.delivery_method = :amazon_ses
ActionMailer::Base.custom_amazon_ses_mailer = AWS::SES::Base.new(:secret_access_key => 'abc', :access_key_id => ''123')
end
And I did replace abc, 123 with the right credentials:
In my main controller I have:
def index
m = Mail.new(:to => "[email protected]", :from => "[email protected]", :subject => "hey", :body => "from controller")
m.deliver!
end
So I think I am following the proper steps, but yet I get Connection refused...
I'm preparing mime-types 2.0 for release, and it has some breaking API changes (not for most uses, but some esoteric features). The most important API change is that mime-types 2.0 no longer supports Ruby 1.8.
If this matters, the gemspec needs to be changed from >= 0 to ~> 1.16.
Bundler could not find compatible versions for gem "mail":
In Gemfile:
aws-ses (> 0.4.1) depends on> 2.2.5)
mail (
rails (= 3.1.0.rc4) depends on
mail (2.3.0)
This is probably an error in my usage, but I can't figure it out.
Mailer.mail_from_address = "Arqball Spin <[email protected]>"
subject = "test"
...
mail :to => "[email protected]",
:from => Mailer.mail_from_address,
:subject => subject
I know that the from address is static and works sometimes, so I cannot understand how to debug the following, which seems to be a problem with the Sender field? Is there any way to print the entire request sent to SES for debugging?
AWS::SES Response Error: InvalidParameterValue - Illegal content.
--- !ruby/exception:AWS::SES::ResponseError
message: 'AWS::SES Response Error: InvalidParameterValue - Illegal content.'
response: !ruby/string:AWS::SES::SendRawEmailResponse
str: !binary |-
PEVycm9yUmVzcG9uc2UgeG1sbnM9Imh0dHA6Ly9zZXMuYW1hem9uYXdzLmNv
bS9kb2MvMjAxMC0xMi0wMS8iPgogIDxFcnJvcj4KICAgIDxUeXBlPlNlbmRl
cjwvVHlwZT4KICAgIDxDb2RlPkludmFsaWRQYXJhbWV0ZXJWYWx1ZTwvQ29k
ZT4KICAgIDxNZXNzYWdlPklsbGVnYWwgY29udGVudC48L01lc3NhZ2U+CiAg
PC9FcnJvcj4KICA8UmVxdWVzdElkPjRhMTBkZmMzLWIxNGItMTFlMy1hNWQz
LWJkZmJkZTgyNTZhMzwvUmVxdWVzdElkPgo8L0Vycm9yUmVzcG9uc2U+Cg==
action: SendRawEmail
response: !ruby/object:Net::HTTPBadRequest
http_version: '1.1'
code: '400'
message: Bad Request
header:
x-amzn-requestid:
- 4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3
content-type:
- text/xml
content-length:
- '268'
date:
- Fri, 21 Mar 2014 22:51:07 GMT
body: |
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>InvalidParameterValue</Code>
<Message>Illegal content.</Message>
</Error>
<RequestId>4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3</RequestId>
</ErrorResponse>
read: true
uri:
decode_content: true
socket:
body_exist: true
body: |
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>InvalidParameterValue</Code>
<Message>Illegal content.</Message>
</Error>
<RequestId>4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3</RequestId>
</ErrorResponse>
parsed:
xmlns: http://ses.amazonaws.com/doc/2010-12-01/
Error: &1
Type: Sender
Code: InvalidParameterValue
Message: Illegal content.
RequestId: 4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3
error: *1
when we run the following test command for ses it returns 220
openssl s_client -crlf -quiet -connect email-smtp.us-east-1.amazonaws.com:465
verify error:num=20:unable to get local issuer certificate
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-XXXXXX XXXXXXX
421 Timeout waiting for data from client.
not able to send emails from 465.
actionmailer (> 3.2) ruby depends on> 2.4.0) ruby
mail (
aws-ses (>= 0) ruby depends on
mail (2.3.3)
Hello,
I'm getting an error when trying to connect to a smtp endpoint email-smtp.us-east-1.amazonaws.com
using my smtp credentials (http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.Credentials.html). It is working, when I use the same credentials and settings in the standard ActionMailer SMTP settings, but I would love to use the aws-ses gem instead.
Error
lib/ruby/1.8/net/http.rb:2030:in `read_status_line': wrong status line: "220 email-smtp.amazonaws.com ESMTP SimpleEmailService" (Net::HTTPBadResponse)
Script
require 'rubygems'
require 'aws/ses'
ses = AWS::SES::Base.new(
:access_key_id => '...',
:secret_access_key => '...',
:server => 'email-smtp.us-east-1.amazonaws.com',
:port => 465
)
email = Mail.new(
:to => '...',
:from => '...',
:subject => 'Test Subject',
:text_body => 'Test Text Body'
)
ses.send_raw_email(email)
Can someone give me a hint, on what I'm doing wrong? Do I have to use different credentials? Am I missing any configuration parameters?
Everything was working fine until 2-3 days ago
now all my calls to "self.ses.send_email...." throw me this error :
NoMethodError (undefined method `bytesize' for nil:NilClass)
If I put my "self.ses" object it looks ok:
Are you aware of anything that changed in the last days that might cause this?
Just tried out this gem, worked very nicely, except when I receive an email to a gmail account there's a (to my uninitiated users persumably alarming) "via email-bounces.amazonses.com" added to the from address shown by gmail. See: https://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=1311182
According to this thread on amazon: https://forums.aws.amazon.com/thread.jspa?threadID=62733
the solution is to use DKIM (for unknown reasons SPF appears to not be sufficient; I'm already using SPF on the domain in question and google tags my messages with "Received-SPF: pass" and "Authentication-Results: mx.google.com; spf=pass").
John Hawthorn has put together a little DKIM gem that might be useful: http://www.johnhawthorn.com/2011/07/introducing-dkim-gem/
Any chance DKIM support could be added to the gem and to the rails support? It would presumably also boost deliverability of the email sent, which would be very useful.
(Yes, I would do it myself, but I'm a bit rusty on ruby these days and would probably make a hash of it... ;)
It would be nice to have a feature built in that would throttle the emails being sent to Amazon to avoid reaching your quota. For instance it could be an option during initialization to set a custom limit or it could default to whatever the max per second quota is that is returned by your SES account. Then throttle the calls to send SES the emails based on your configured limit.
I'm trying to follow down the code path and it looks like this is passed along in the AWS::SES::SendMail#send_email method, but not AWS::SES::SendMail#send_raw_email. I was curious either a) it is and I'm missing it somewhere, or b) it is not and then why not? Otherwise how can I send with a certain from/source address for people who hit Reply to and have a different email handle bounces/rejections?
Related to this, looking at AWS::SES::SendMail#send_email it seems like it takes :return_path and adds it as package["ReturnPath"]; I couldn't find where that makes its way into the request headers to the API, but shouldn't that be "Return-Path" per AWS SES's spec?
Thanks,
\Peter
I'm trying to get Amazon SES to correctly forward me any bounced emails. I've set the return path via ActionMailer but still when sent it uses Amazon's bounce email address. Am I missing something?
I see that some core part(s) of this gem were taken from aws-s3, namely
lib/aws/ses/extensions.rb
When both gems are included in a Gemfile for instance then the following exception is raised on boot:
/Users/codyc/.rvm/gems/ree-1.8.7-2010.02/gems/aws-ses-0.3.1/lib/aws/ses/extensions.rb:206:in const_missing_not_from_s3_library': stack level too deep (SystemStackError) from /Users/codyc/.rvm/gems/ree-1.8.7-2010.02/gems/aws-ses-0.3.1/lib/aws/ses/extensions.rb:206:in
const_missing_not_from_s3_library'
from /Users/codyc/.rvm/gems/ree-1.8.7-2010.02/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
It would be nice if both gems could be included - maybe by detecting the presence of these extensions and conditionally loading them
amanzon-ses - support pdf attachment, when i send a litte size file(12kb) everything is ok, when i send larger file(200kb) one of the two recipients doesnt deliver, error while sending. when i send file about 700kb nothing is delivered :( error code: "Errno::EPIPE (Broken pipe):" but every time differnt error codes. it seems error fires when time out expired and returns connection brokes that fires error. is amazon ses service have any time out to send eamil?
thanks.
Hi,
Is it possible to send mail with CSV attachment via Amazon SES? The below code does not work for :ses, but work for :smtp
attachments[filename] = {:content => csv_string, :mime_type => 'text/csv' }
mail(:to => "[email protected]", :from => "[email protected]", :bcc => "[email protected]", :subject => "Hello World" )
Thanks
AWS SES is deprecating those 2 signing methods for authentication. The only method supported in the future will be signature v4.
After doing some testing with configuration like this, this gem does not appear to be using the v4 signing method despite passing in the :signature_version => 4
It looks like this might be happening because this line
Line 180 in 532ab65
signature_version
which then gets compared to an integer when checking the conditional down here Line 199 in 532ab65
It looks like this might have been introduced right here f4ef27d#diff-b36a5e73febe42aa0b75b3a526a815d1L191 when the "v" got dropped maybe?
I'm using this gem with rails 3.1.1 and whatever I do I keep getting error:
AWS::SES::ResponseError (SignatureDoesNotMatch - The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.)
I'm sending this using the ActionMailer configuration option
Can we use a faster http library other than the native net::http library?
Also, is it possible to submit the http request asynchronously? Otherwise it will block the request.
Hi,
I got this error while executing below command. I tried a lot but can't figure it out.
ses = AWS::SES::Base.new(:access_key_id =>'MY20DIGITACCESSKEY',:secret_access_key =>'MYSECRETACCESSKEY',:server => 'email-smtp.eu-west-1.amazonaws.com')
ses.quota
Error is:
Net::HTTPBadResponse: wrong status line: "220 email-smtp.amazonaws.com ESMTP SimpleEmailService-909942753 Wfwzt4Zk5WWKpNsmFazj"
from /home/shreehari/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http/response.rb:41:in `read_status_line'
I've got a Sinatra app which uses the Sequel library for talking to my Sqlite3 database. By default Sequel wants plural table names and singular model names (just like ActiveRecord).
When I require 'aws/ses'
, it causes Sequel to look for database tables with singular names instead of plural! I'll get errors on every page (the table name is actually events):
Sequel::DatabaseError at /events/codeconf
SQLite3::SQLException: no such table: event
If I go and change all my database tables to the singular version, the app works again. As soon as I remove aws-ses
, everything goes back to normal. I haven't discovered why this happens yet...any ideas?
Hi, there is a way to know which email has bounced and not just the bounces numbers?
If it is not, which is the better strategy to know the email bounced?
Thank you
How to correctly create and setup access_key_id and secret_access_key in Amazon Simple Email Service (SES), for aws-ses gem? In the description of the gem it is written to provide exactly them in the credentials file, but I can't figure out how to create them.
I tried to create a new user through Identity and Access Management (IAM) specifying full access to Amazon SES and using those keys, but it didn't work.
Is it possible to use this gem with Rails 2.2.x? If not, any idea of what it would take to make that possible?
Thanks a lot
Robert
Here's the email I got about an impending deprecation:
Hello,
Amazon Web Services currently supports Amazon SES API requests that are signed using Signature Version 3 and Signature Version 4 processes. Signature Version 4 further enhances the security around authentication and authorization of Amazon SES customers by using a signing key instead of your secret access key. To improve the security for our customers, beginning October 1, 2020, Amazon Signature Version 3 will be turned off (deprecated) in Amazon SES in favor of Signature Version 4.
Amazon SES customers who are still using Signature Version 3 must migrate to Signature Version 4 by September 30, 2020. After that, Amazon SES will only accept requests that are signed using Signature Version 4. For more information, see Signature Version 4 signing process [1].
Is anywone working on updating this gem to support V4? Or should I look for a different gem?
Saw your comment over http://robots.thoughtbot.com/post/3105121049/delivering-email-with-amazon-ses-in-a-rails-3-app that it is possible to get the Message-ID that SES generated back, but is is not clear to me how.
Note: I tried setting my own Message-ID as others have reported that amazon ses just moves that to the "In-Reply-To" when it generates its own, but I'm not seeing that behavior. Basically, I'm trying to track replys back to the original email. Custom headers (X-...) are stripped by gmail.
Hello is it possible to create a Custom Verification Email Template Request with this gem?. I am using rails. Thanks
I'm trying to use aws-ses with my Rails 3.0.3 project (Ruby 1.9.2-p136), but WEBrick is croaking when I try to send a mail. Also dies in the console trying to do something like ses.addresses.list. Here's the error, trimmed quite a bit.
net/http.rb:677: [BUG] Segmentation fault
Any ideas? I've read several blogs about settings things up, and the Amazon Perl scripts all work fine. Thanks!
I upgraded the gem to the last release, and now when I send an email I receive this error message.
IncompleteSignature - Request must contain a signature that conforms to AWS standards
/.rvm/gems/ruby-2.3.3/gems/aws-ses-0.7.1/lib/aws/ses/base.rb:190:in `request'"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.