Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Ref:</strong> <a href="https://stackoverflow.com/questions/691881/determine-if-asp-net-application-is-running-locally">Determine if ASP.NET application is running locally</a> and <a href="http://forums.asp.net/p/1065813/4081335.aspx" rel="nofollow noreferrer">How secure is Request.IsLocal?</a> </p> <blockquote> <p>As per the comment the best way to check for <code>localhost</code> using <code>HttpContext.Current.Request.IsLocal</code> property. It is same as like Request.IsLocal is the same as checking for 127.0.0.1 or ::1.</p> </blockquote> <p>use this:</p> <pre><code>bool isLocal = HttpContext.Current.Request.IsLocal; if(isLocal) then fetch gmail credentials else if (myconnection==online) then fetch godaddys credentials </code></pre> <p>Sample code snippet to send mail through gmail is:</p> <pre><code>SmtpClient mailClient = new SmtpClient(); //This object stores the authentication values System.Net.NetworkCredential basicCredential = new System.Net.NetworkCredential("username@mydomain.com", "****"); mailClient.Host = "smtp.gmail.com"; mailClient.Port = 587; mailClient.EnableSsl = true; mailClient.DeliveryMethod = SmtpDeliveryMethod.Network; mailClient.UseDefaultCredentials = false; mailClient.Credentials = basicCredential; MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress("info@mydomain.com", "Me myself and I "); message.From = fromAddress; //here you can set address message.To.Add("to@you.com"); //here you can put your message details mailClient.Send(message); </code></pre> <p>if these setting match to configuration then you are definitly able to send mail through gmail. </p> <p>Check your this section of settings.</p> <pre><code> NetworkCredential NetCrd = new NetworkCredential(youracc, yourpass); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = NetCrd; </code></pre> <p><strong>Edit</strong> </p> <p>follow these links, these are not the exact reason of your problem but guide to solve this on your local machine:<br> <a href="http://answers.microsoft.com/en-us/windowslive/forum/livemail-sync/i-can-receive-mail-but-not-send-from-an-account-i/5fd32347-5970-443a-86d2-ad7ef4df8709" rel="nofollow noreferrer">I can receive mail but not send from an account I set up in windows live mail</a><br> <a href="https://stackoverflow.com/questions/4690354/sending-email-using-gmail-account-on-local-machine">sending email using gmail account on local machine</a></p> <p>Another aspect is that you can check the local machine ip or machine name to figure out either website on remote server or your own machine using the <a href="http://msdn.microsoft.com/en-us/library/h55b6cak.aspx" rel="nofollow noreferrer">HttpRequest Class</a> <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx" rel="nofollow noreferrer">HttpRequest.UserHostAddress Property</a>.</p> <p>If Ip matches to ip request object returns ip address to your machine address.</p> <pre><code>if (ip match to your machine)// local host else run your remote settings </code></pre> <p>Ref:<br> <a href="http://HttpRequest.UserHostName%20Property" rel="nofollow noreferrer">Request.UserHostName</a><br> <a href="https://stackoverflow.com/questions/2019431/how-to-get-the-ip-address-of-a-machine-in-c-sharp">How to get the IP address of a machine in C#</a><br> <a href="https://stackoverflow.com/questions/4260975/get-remote-ip-address-or-machine-name">get remote Ip address or machine name</a></p>
    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.
    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