我有一个允许用户向朋友发送邀请的应用程序。正在使用 SendGrid 发送电子邮件。我想知道如果用户输入不存在的电子邮件地址,是否可以将 mailer-daemon 电子邮件转发回给用户。
例如,用户输入电子邮件“thisisnotreal@fakedomain1234.com”以发送邀请。我希望能够通知用户他们输入的电子邮件不存在。通常,当您只是从电子邮件客户端发送电子邮件时,服务器会立即让您知道电子邮件无法送达。我想知道是否可以通过 SendGrid 来做到这一点。
我有一个允许用户向朋友发送邀请的应用程序。正在使用 SendGrid 发送电子邮件。我想知道如果用户输入不存在的电子邮件地址,是否可以将 mailer-daemon 电子邮件转发回给用户。
例如,用户输入电子邮件“thisisnotreal@fakedomain1234.com”以发送邀请。我希望能够通知用户他们输入的电子邮件不存在。通常,当您只是从电子邮件客户端发送电子邮件时,服务器会立即让您知道电子邮件无法送达。我想知道是否可以通过 SendGrid 来做到这一点。
Take a look at the event notification section of the SendGrid API. You can add a page to your application that accepts POST requests from SendGrid, and then you'll get event notifications in real-time.
When a bounce event is posted to that listener from SendGrid, you could then lookup the user that needs to be notified via the recipient email. If you don't have this relationship available in your local store, you could pass a unique argument to SendGrid at send time that contains information you can use for the lookup - unique arg information is included with event notifications. Then it's just a matter of taking the appropriate action required to notify your user - either with an email or via a notice on your website or a text message or whatever is best for your application.
This maintains asynchronous communication. You'll be alerted when something goes wrong without having to add blocking code, and you can send your users a nice branded message (using SendGrid, of course) rather than just forwarding a mailer-daemon response .