开发者

How do i obtain my smtp host?

开发者 https://www.devze.com 2023-03-05 00:12 出处:网络
i program a site. and i want to send a message to the user.. now in asp.net in the config file.. i put this:

i program a site. and i want to send a message to the user.. now in asp.net in the config file.. i put this:

<mailSettings>

  <smtp from="makovetskiyd@yahoo.co.uk">

    <network host="localhost" port="25" userName="username" password="secret" defaultCredentials="true" />

  </smtp>

</mailSettings>

i have no idea how the network host acts and what it does.. i want to change it to the server that holds my yahoo account. i understand that smtp is some email server that sends emails out.. but how do i put obtain it? how does it look like,? is it an int, is it a string?!?

 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);

config file:

    <mailSettings>

  <smtp from="makovetskiyd@yahoo.co.uk">

    <network host开发者_Python百科="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>


Look at Yahoo! Mail help pages for settings for their SMTP server. It looks like you need to be a Yahoo! Mail Plus account holder to access POP and SMTP servers however. Maybe you can use another mail account - your web hosting provider's SMTP server would be the best one to use. Read your web host's help pages.


Network host is the address of the physical server (SMTP server) that will handle the sending of email. It could be in a form of IP address or a domain name (e.g. mail.mydomain.com). If you are working on a company they should provide this to you,


using System.Configuration;
using System.Web.Configuration;
using System.Net.Configuration;

Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("PathToConfigFile");

Alternative

configurationFile = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath)

MailSettingsSectionGroup mailSettings = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号