我使用SmtpClient發送電子郵件這樣C#SMTP客戶端,設置發送從參數
MailMessage mail = new MailMessage("[email protected]", "[email protected]", "Contact from " + emailFrom, text);
SmtpClient client = new SmtpClient();
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(emailAccount, accountPass);
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Send(mail);
這是工作的罰款,我收到郵件,但我收到來自emailAccount地址變量電子郵件。我想收到來自郵件的'From'字段的電子郵件,例如[email protected]
是否有可能?
上[此]所選擇的答案(http://stackoverflow.com/questions/4243300/setting-a-different-from-address-for- mail-via-gmail-using-c-sharp?rq = 1)問題暗示GMail的SMTP服務器不允許更改From字段。 – Martheen