【发布时间】:2011-05-10 09:41:28
【问题描述】:
我编写了一个网站。我想向用户发送一条消息.. 现在在配置文件中的 asp.net 中.. 我把这个:
<mailSettings>
<smtp from="makovetskiyd@yahoo.co.uk">
<network host="localhost" port="25" userName="username" password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
我不知道网络主机的行为方式和作用。我想将其更改为拥有我的雅虎帐户的服务器。我知道 smtp 是一些发送电子邮件的电子邮件服务器.. 但是我如何获取它?它看起来怎样,?是int,还是字符串?!?
MailMessage message = new MailMessage();
message.From = new MailAddress("makovetskiyd@yahoo.co.uk");
message.To.Add(new MailAddress("makovetskiyd@yahoo.co.uk"));
message.CC.Add(new MailAddress("makovetskiyd@yahoo.co.uk"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
配置文件:
<mailSettings>
<smtp from="makovetskiyd@yahoo.co.uk">
<network host="smtp.yahoo.com" port="25" userName="username" password="secret" defaultCredentials="true" />// where do i get the host?!? the host prevents me from sending an email
</smtp>
</mailSettings>
【问题讨论】:
-
这取决于您要使用的 smtp 服务器...如果您要使用的是您的 ISP 的 smtp 服务器,您可以询问您的 isp(或在他们的网站上搜索)。雅虎或任何其他邮件服务也是如此。您必须从他们那里获得正确的 smtp 服务器(即他们的支持网站)。
-
另外:这与 Stack Overflow 无关。 SuperUser 或 WebApps 可能会更好。