通过Gmail在C#中发送邮件时更改发件人地址

问题描述:

我已经用下面的code从使用Gmail帐户我的web应用程序发送邮件..我可以更改发件人地址到另一个地址以外的原始发件人(Gmail地址)。

I ve used the following code to send mail from my web application using a gmail account.. Can i change the sender address to another address other than original sender(gmail) address..

 System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();


System.Net.NetworkCredential cred = new 
       System.Net.NetworkCredential("sample@gmail.com", "*******");

我总是收到来自 sample@gmail.com 邮件。是否有可能改变呢?

I always receive mail from sample@gmail.com. Is it possible to change it?

我已经改变
     mail.From =新System.Net.Mail.MailAddress(sample@yahoo.com); ,但我收到邮件的发件人地址 sample@gmail.com ,而不是从地址新。我认为Gmail的SMTP与原始凭证将覆盖从地址...

I ve 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 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.

这不要紧,你用什么,他们在写,他们传递它之前。这prevent垃圾邮件/欺骗。

It doesn't matter what you use, they over-write it, before they relay it on. This prevent spamming/spoofing.