Reputation: 5132
I’m trying to build a rails app that will process inbound mail. I got the app to work on my localhost machine using the Rails conductor and action mailbox. When an email gets sent, I’m able to save the contents of the email. But I’m having difficulty getting it to work on a production environment…I’m not sure how to configure my domain and settings to get it to work.
I’ve been following the instructions here: https://edgeguides.rubyonrails.org/action_mailbox_basics.html#sendgrid and https://sendgrid.com/docs/for-developers/parsing-email/setting-up-the-inbound-parse-webhook/
I included this in my rails credentials:
action_mailbox: ingress_password: mypassword
I have set up an MX record on google domains:
parse.[mydomain].com
I pointed to a Hostname and URL.
https://actionmailbox:mypassword@parse.[mydomain].com/rails/action_mailbox/sendgrid/inbound_emails
I send an email from my email account to
parse@parse.[mydomain].com
but I’m not able to test or track what is happening to this email. I don’t receive an error message back to my email as a reply, so I think that’s a good sign but I’m not sure whether it’s being processed or how to troubleshoot. I even put a puts ‘test’ in my replies_mailbox.rb file but I don’t see anything in the console when I tail logs on production.
Any advice on what next steps I can take?
Upvotes: 3
Views: 1306
Reputation: 25
I spent two weeks on what seems like this same issue and found one possible answer that worked for me, crossposted in SendGrid's GH Issues: https://github.com/sendgrid/opensource/issues/22):
Problem:
Solution:
I used NGINX and CertBot. To update them:
sudo NGINX -T
to see what your current configuration is, and where it is.sudo /etc/nginx/snippets/ssl-params.conf
(or whatever your actual path and preferred editors are.. and make sure to use the path from the -T
call b/c you might end up updating the wrong config).ssl_protocols
.... you need to update it to read ssl_protocols TLSv1.3 TLSv1.2;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparam.pem;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
sudo service nginx configtest
and then restart NGINX with sudo service nginx restart
I then sent another inbound parse to SenGrid and was able to confirm that it hit my site, was logged, and was processed.
Upvotes: 0
Reputation: 18444
When dealing with integration testing it's useful to split the issue into smaller ones, in order of email path
params[:email]
, other fields are not necessary:
curl -X POST "https://actionmailbox:mypassword@parse.[mydomain].com/rails/action_mailbox/sendgrid/inbound_emails" \
-F email="From: foo <abc@localhost>\nTo: bar <bca@localhost>\nSubject: test\nMIME-Version: 1.0\n\nTest!"
I'd start with #5, to be sure your app is accepting email correctly and has logs, and then go up.
PS. puts
might not appear in logs in production (or not where you expect it to appear) depending on you logging setup. Better way is to use Rails.logger.info
Upvotes: 1