使用谷歌 SMTP
我正在使用 Google SMTP 从我的应用程序发送电子邮件。 邮件发出得很好。但发件人地址始终设置为验证电子邮件。 这是设计使然吗?
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "mypwd");
smtpClient.EnableSsl = true;
MailMessage message = new MailMessage();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
message.From = new MailAddress("[email protected]", "GuestName");
最后一行应代表访客电子邮件发送邮件。
不知何故,我总是看到它设置为“[email protected]”,而不是“[电子邮件受保护]”
这是设计使然还是 Google 不允许那样设置?
我怎样才能做到我上面说的呢?
基本上,我的客人向其他一些人发送邮件。我需要我的客人知道哪些电子邮件被退回。
I am using Google SMTP for sending out emails from my app.
The mails go out fine. But the from address is always set to the verification email.
Is this by design?
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "mypwd");
smtpClient.EnableSsl = true;
MailMessage message = new MailMessage();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
message.From = new MailAddress("[email protected]", "GuestName");
This last line should send the mail on behalf of the guest email.
Somehow I always see this is set to "[email protected]", not "[email protected]"
Is this by design or Google won't allow to set it that way?
How can I do what I said above?
Basically, my guest sends mail to a number of other people. I need my guest to know which emails has bounced.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在 gmail.com 上验证要从中发送邮件的帐户。您可以在“设置”->“设置”中找到该设置。账户和导入 ->发送邮件为。
You have to verify the account you want to send mail from at gmail.com. You can find the setting at Settings -> Accounts and Import -> Send mail as.