问题
I have the same concept as mentioned in this question(generating a unique random email address for each user in rails app. When the user sends an email that that randomly generated email address, we process the body and store in db.
I followed the following steps:
- Deployed my app in Heroku
- Created a sendgrid account and configured the
username
andpassword
to heroku(to get the sendgrid addon). - added griddler gem and followed the steps mentioned in griddler.
- Configured the parse webhook in sendgrid with my host and url.
Here comes the main problem:
I registered to coludmailin and it generated the single email address. I don't really understand how to receive uniq emails to my rails application now. I tried white labeling the cloudmailin.net
in sendgrid but it doesn't work(may be am wrong here).
Googled a lot but didn't understand how to proceed from here. Can someone please help me in solving this issue. Appreciate if I get a good step-by-step reference
回答1:
There are two options to do this with CloudMailin.
Option 1:
On the free plan you can use a +
in order to separate the email address given to you on CloudMailin and still create a unique email address that each customer can respond to. For example:
If you CloudMailin email address is example1234@cloudmailin.net
you can use example1234+unique_id_54321@cloudmailin.net
. CloudMailin calls unique_id_54321
the disposable part of this email address. This way you can send an email out and state the sender of that email is example1234+unique_id_54321@cloudmailin.net
and then tell one user from another.
Option 2 (the better option):
However, the best way to do this is to use CloudMailin's custom domains. You can then receive anything@yourdomain.com
.
With custom domains enabled you set CloudMailin up to be your MX server. Then any email coming into yourdomain.com
goes direct to CloudMailin (you can use app.yourdomain.com
to avoid conflicts with your regular email if needed).
You can then send email out with the sender as user-12345@yourdomain.com
, task-12345@yourdomain.com
or any other unique identifier. When you receive the email from CloudMailin the envelope will show that the email was sent to user-12345@yourdomain.com
and you can then use this to resolve who the user was.
来源:https://stackoverflow.com/questions/35382172/receiving-emails-with-sendgrid-and-cloudmailin