问题描述
我已使用以下代码使用 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发送邮件时更改发件人地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!