发送来自地址问题的电子邮件 [英] sending email with from address issue
问题描述
嗨朋友们,
我已经开发了我的客户联系我们(我正在开发网站的一家公司)。因为我已经写了一封发送邮件的代码。我成功发了邮件。我使用stmp.live.com作为主机,useraname是我的电子邮件ID(info@dhuvara.com),来自我的邮件服务器和密码。这里的目的地电子邮件(收件人地址)是我的客户电子邮件ID(例如:info@domail.com)。访问过他们网站的人通过发送详细信息(包括他们的电子邮件ID作为来自地址)从联系我们页面发送查询但我的问题是在目的地emaild收件箱中,他们从我的地址收到邮件(info@dhuvara.com,这显示为来自地址)。但我希望来自地址必须是从地址联系我们页面输入的地址。
感谢您提前
当您创建MailMessage对象时,属性为 From MailMessage 对象是客户端查看邮件来源的实际地址。
string mailFrom = test@gmail.com跨度>;
var mailMessage = new MailMessage
{
Subject = subject,
Body = body,
IsBodyHtml = true ,
来自 = new MailAddress( mailFrom )
};
var smtpClient = new SmtpClient
{
Host = Configuration.Current.Smtp.Host,
Port = Configuration.Current.Smtp.Port,
};
if (!string.IsNullOrEmpty(Configuration.Current.Smtp.UserId))
{
smtpClient.Credentials = new NetworkCredential(Configuration.Current.Smtp.UserId,Configuration.Current.Smtp.Password);
}
mailClient.Send(message);
Hi friends,
I have developed contact us for my client(one company for that i am developing website). in that i have write a code for sent a mail. I sent a mail successfully. I am using stmp.live.com for host and useraname is my email id (info@dhuvara.com)from my mail server and with password. Here destination email (To address) is my client email id(ex; info@domail.com). whoever visited their website sent enquiry from contact us page by sending details including their email id as a from address. but my problem is in destination emaild inbox they got mail from my address(info@dhuvara.com, this is shows as the from address).but i want the from address must be the address that typed from the contact us page from address.
Thanks in Advance
when you create MailMessage object the property "From" of MailMessage object is the actual from address where client see where the mail comes.
string mailFrom = "test@gmail.com"; var mailMessage = new MailMessage { Subject = "subject", Body = "body", IsBodyHtml = true, From = new MailAddress(mailFrom) }; var smtpClient = new SmtpClient { Host = Configuration.Current.Smtp.Host, Port = Configuration.Current.Smtp.Port, }; if (!string.IsNullOrEmpty(Configuration.Current.Smtp.UserId)) { smtpClient.Credentials = new NetworkCredential(Configuration.Current.Smtp.UserId, Configuration.Current.Smtp.Password); } mailClient.Send(message);
这篇关于发送来自地址问题的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!