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发送邮件时更改发件人地址
基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01