0
votes

We have develop an application that sends email to the user after he confirms a visit to our branch. It works fine when we use the following Gmail configuration: Email: [email protected] Passwd: XXXXX SMTP Server: smtp.gmail.com Port: 587 However, when we try using our domain-based account it simply dosen't work. We are using the following parameters: Email: [email protected] Passwd: XXXXX SMTP Server: smtpout.secureserver.net Port: 465

Code snippet below:

 using (System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(from, to))
            {
                mm.Subject = subject;
                mm.Body = body;
                mm.IsBodyHtml = false;
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential(from, password);
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Host = smtpHost;
                smtp.Port = smtpPort;
                try
                {
                    smtp.Send(mm);
                }
                catch (Exception ex)
                {
                    throw ex;  
                }                
            }
            return;
        }

Is there anything missing? Suggestions are welcome.

Thx

1
You catch an exception, and then throw one. Maybe take a look at the actual error message if there is one?VDWWD
The problem might be in google account. From your google account in “sing in and security settings” make sure less security apps enabled (it’s in bottom of security page). If you’re using 2fa you can generate a new password for the app only.thatway_3

1 Answers

0
votes

Check the SmtpStatusCode first.

try
    {
  client.Send(message);
    }
    catch (SmtpException e)
    {
    Console.WriteLine("Error: {0}", e.StatusCode);
    }

Try set EnableSsl to False.

Finally, you can lookup the server your email is associated to by logging into your godaddy account, launching the email service, click on "Domains" in the left nav, the click on server addresses in the horizontal nav.