Overview:
Our use case involves using the SendGrid Inbound Parse to accept, record and process emails. We also need those emails to be forwarded to our ticketing system (i.e. Zoho Desk).
We would really like to be able to forward the unedited email to Zoho Desk, preserving the original From, To, etc.
Problem(s):
When we try to forward the email using SendGrid's SMTP server, and using the MimeKit.MimeMessage.ResentTo("[email protected]") option, SendGrid is rejecting the forward request because of "Sender Authentication". The error we're getting from SendGrid is:
The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements.
Below is the code we're using:
SmtpClient cli = new SmtpClient();
cli.Connect(_config["SendGrid:Server"], int.Parse(_config["SendGrid:Port"]), true);
cli.Authenticate(_config["SendGrid:Username"],_config["SendGrid:ApiKey"]);
message.ResentSender = null;
message.ResentFrom.Clear();
message.ResentReplyTo.Clear();
message.ResentTo.Clear();
message.ResentCc.Clear();
message.ResentBcc.Clear();
message.ResentFrom.Add(MailboxAddress.Parse(_config["SendGrid:From"]));
message.ResentReplyTo.AddRange(message.ResentFrom);
message.ResentTo.AddRange(from o in matches
select MailboxAddress.Parse((string)o.ticket_addr));
message.ResentMessageId = MimeUtils.GenerateMessageId();
message.ResentDate = DateTimeOffset.Now;
cli.Send(message);
Question(s):
- Is there a way with SendGrid we can forward the inbound email to Zoho Desk while preserving the From fields?
- I would imagine SendGrid isn't the only company requiring Sender Authentication, as such, how else can we forward unedited emails to a ticketing platform?
CodePudding user response:
Twilio SendGrid developer evangelist here.
SendGrid does require you to verify, via Single Sender Verification or Domain Authentication, email addresses from which you wish to send emails. So you cannot use SendGrid to automatically forward keeping the from email intact.
I have a couple of ideas about workarounds here though.
You could forward from your verified email address and add the original from email address in a reply-to field. I haven't worked with Zoho Desk, but perhaps you could configure it to respect that field instead of from.
Zoho has a guide on how to set up forwarding from various inboxes. Could you host your email with one of those providers and forward incoming emails onto Zoho and to your SendGrid email address for this processing?