Note that there are some explanatory texts on larger screens.

plurals
  1. POsending emails from localhost and online asp.net
    primarykey
    data
    text
    <p>I know how to send email through smtp in code in c#</p> <p>if i set a gmail smtp it works fine in localhost but when i upload and make it online then gmail (smtp.gmail.com) settings dont work. i have to change settings everytime to (relay-hosting.secureserver.net) at godaddy after uploading </p> <p>Now my question is! Is there any way i can find out if im on localhost in code or online then change the settings dynamically im storing my settings in db my working code is </p> <pre><code>mm.LoadByPrimaryKey(4);//get body , subject etc from db mc.LoadByPrimaryKey(1);// get settings from db (host, from , port etc) var maTo = new MailAddress(strEmail, userName); var mMailMessage = new MailMessage { Subject = mm.Subject, Body = strBody, IsBodyHtml = true, Priority = MailPriority.High, From =new MailAddress(mc.AdminEmailAddress), DeliveryNotificationOptions= DeliveryNotificationOptions.OnFailure }; mMailMessage.To.Add(maTo); var mSmtpClient = new SmtpClient { UseDefaultCredentials = false, Host = mc.Host, Credentials = CredentialCache.DefaultNetworkCredentials, DeliveryMethod = SmtpDeliveryMethod.Network}; mSmtpClient.Send(mMailMessage); </code></pre> <p>i dont want to change my settings everytime, wether im online or developing in localhost environment<br> i want this flow and how do i know my application is online or localhost in code behind</p> <pre><code>if(myconnection ==localhost) then fetch gmail credentials else if (myconnection==online) then fetch godaddys credentials </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload