change sender address when sending mail through gmail in c#(在c#中通过gmail发送邮件时更改发件人地址)
问题描述
我已使用以下代码使用 gmail 帐户从我的 Web 应用程序发送邮件.我的问题是,我可以将发件人地址更改为原始发件人(gmail)地址以外的其他地址吗?我的代码如下:
I have used the following code to send mail from my web application using a gmail account. My question is, can i change the sender address to another address other than original sender(gmail) address? My code is as follows:
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("sample@gmail.com", "*******");
无论我做什么都是无用的,因为我总是收到来自 sample@gmail.com
的邮件.可以改吗?
Whatever i do is useless as i always receive mail from sample@gmail.com
. Is it possible to change it?
我已经改成mail.From = new System.Net.Mail.MailAddress("sample@yahoo.com");
但我收到了来自地址 sample@gmail.com
的邮件而不是来自新的发件人"地址.我认为 gmail smtp 会用原始凭据覆盖发件人地址.
I have changed to
mail.From = new System.Net.Mail.MailAddress("sample@yahoo.com");
but i received the mail with the from address sample@gmail.com
and not from the new "From" address. I think gmail smtp overwrites the from address with the original credential.
推荐答案
Gmail 不允许您将 FROM 更改为不同于您的 gmail 帐户的内容.
Gmail doesn't allow you to change the FROM to something different than your gmail account.
无论您使用什么,他们都会在转发之前覆盖它.这可以防止垃圾邮件/欺骗.
It doesn't matter what you use, they over-write it, before they relay it on. This prevent spamming/spoofing.
这篇关于在c#中通过gmail发送邮件时更改发件人地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在c#中通过gmail发送邮件时更改发件人地址


- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01