从ASP.Net发送电子邮件,发件人地址不正确地显示给收件人 [英] Sending Email from ASP.Net, From address not shown correctly to the recipient

查看:263
本文介绍了从ASP.Net发送电子邮件,发件人地址不正确地显示给收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临一个问题,当我从我的ASP.Net应用程序发送电子邮件。有在发送邮件没有错误,但在由接收者接收电子邮件,从电子邮件地址被示为网络凭证的用户名。

I am facing an issue when I send email from my ASP.Net application. There is no error in sending the mail, but when the email is received by the recipient, the from email address is shown as the username of network credential.

在我而言,我使用 smtp.gmail.com 作为SMTP主机和用户名和密码也是我的Gmail帐户。

In my case, I am using smtp.gmail.com as smtp host and the user name and password are also of my gmail account.

MailMessage mail = new MailMessage();
mail.From = new MailAddress("abc@mydomain.com", "Enquiry");
mail.To.Add("munjal.pandya@yahoo.com");
mail.IsBodyHtml = true;
mail.Subject = "Registration";
mail.Body = "Some Text";
mail.Priority = MailPriority.High;

SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
//smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "<my gmail pwd>");
smtp.EnableSsl = true;
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);

显示给收件人的地址是 xyz@gmail.com 。但实际上它应该是 abc@mydomain.com

The From address shown to the recipient is xyz@gmail.com. But actually it should be abc@mydomain.com.

如果任何人有关于这个问题的一个想法,请让我知道。

If anyone have an idea regarding this issue, please let me know.

推荐答案

这不是编码问题,只需添加电子邮件abc@mydomain.com作为附加的地址在Gmail和验证。

It's not the coding issue, just add email abc@mydomain.com as additional address in gmail and verify it.

在Gmail界面:设置 - >账户 - >发送字母...

In gmail interface: Settings -> Accounts -> Send letters as ...

这篇关于从ASP.Net发送电子邮件,发件人地址不正确地显示给收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆