Note that there are some explanatory texts on larger screens.

plurals
  1. POSending Email In C# MVC..On Local host..not working?
    primarykey
    data
    text
    <p>Im trying to send out a basic email, using C# mvc...for some reason it wont work.. i tried many different solutions, but keep getting same error in browser that says" operation has timed out"..which i think is a connection problem. Error starts at" client.Send(mail); im doing this on my local machine.I tried using port 587,465,995,25, but no luck. I dont get any errors, in the compiler in Visual Studio, when i build it. I just get the error, in the web browser, on line" client.Send(mail);"</p> <p>Controller:</p> <pre><code> public void SendEmail(History hi) { SmtpClient client = new SmtpClient(); //server type client.Port = 587; client.Host = "smtp.gmail.com"; //google client.EnableSsl = true; //SSl set to true client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("papasmurf985@gmail.com", "******"); MailMessage mail = new MailMessage("papasmurf985@gmail.com", "papasmurf985@gmail.com", "Test Score", "Your score is" + hi.score); mail.BodyEncoding = System.Text.Encoding.UTF8; mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(mail); } </code></pre> <p>web.config:</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp deliveryMethod="Network"&gt; &lt;network host="smtp.gmail.com" port="587" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre> <p>I also tried this in web.config:</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp from="no-reply@no-reply.com"&gt; &lt;network host="smtp.gmail.com" port="587" enableSsl="true" userName="papasmurf985@gmail.com" password="PASSWORD" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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