使用Azure Communication Service发邮件时URL被改写为azurecomm.net求助
解决Azure Communication Services邮件URL被重写为azurecomm.net的问题
问题原因
Azure Communication Services(ACS)邮件服务默认会对根域名级别的跳转链接(如https://example.com)进行重写,生成azurecomm.net格式的跳转链接。这么做是为了跟踪点击数据,同时降低邮件被反垃圾系统标记的概率。而带路径的URL(如https://api.example.com/test)因为指向更具体的资源,默认不会触发这个重写规则。
解决方案
你可以通过以下两种方式避免根域名URL被重写:
1. 全局禁用所有链接重写
在发送邮件的请求中添加disableLinkRewriting参数并设为true,这样所有链接都会保持原始格式:
- C# SDK示例:
var emailMessage = new EmailMessage( senderAddress: "sender@yourcompany.com", recipientAddresses: new List<string> { "user@example.com" }, content: new EmailContent("Company Website") { Html = "<p>访问我们的官网:<a href=\"https://example.com\">example.com</a></p>" } ) { DisableLinkRewriting = true };
- REST API示例:
{ "senderAddress": "sender@yourcompany.com", "recipients": { "to": [{"address": "user@example.com"}] }, "content": { "subject": "Company Website", "html": "<p>访问我们的官网:<a href=\"https://example.com\">example.com</a></p>" }, "disableLinkRewriting": true }
2. 仅禁用特定链接的重写
如果你需要保留其他链接的跟踪功能,只需在目标链接的HTML锚点标签中添加data-skip-link-rewrite="true"属性:
<a href="https://example.com" data-skip-link-rewrite="true">我们的官网</a>
这样这个根域名链接会保持原始地址,其他链接仍会被ACS重写用于点击统计。
内容的提问来源于stack exchange,提问作者J Singh
相关产品推荐
相关产品推荐

