0

I have a form that sends me a email to my gmail for work email address. The email address works, just not from my website app. (Using asp mvc)

I tested this code to work on godaddy with their email and with my personal gmail and it works, but not with google business, I get a syntax error. I believe its set up correctly base off google settings https://support.google.com/a/answer/176600?hl=en

This is what I got set up

            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = "mysite@example.com",
                    Password = "password"
                };

                smtp.Credentials = credential;
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 465;
                smtp.EnableSsl = true;
                await smtp.SendMailAsync(message);
                await smtp.SendMailAsync(CustomerMsg);
                return RedirectToAction("Sent");
            }
        }

         return View(model);

the error I'm getting is

System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was:

the error is at this line

Line 79:await smtp.SendMailAsync(message);

1 Answers1

0

https://stackoverflow.com/a/23441014/6194650

I'm not sure if you already looked at this, but just searching your error sometimes helps.

Community
  • 1
  • 1
Adam Lynch
  • 331
  • 2
  • 6
  • I saw that one and my personal gmail mail works and everything it's just when I use google business email settings it doesn't work. You think could be a server name or host name could be wrong? –  Apr 12 '16 at 19:50
  • @theone it was the second part of that answer that I posted that I thought you should look at "It looks like you are using POP3 or IMAP server not SMTP Server, please check configuration of your Server" Hope this helps. – Adam Lynch Apr 12 '16 at 20:15
  • Yeah I will check it out to find a solution, and let everyone know the reason –  Apr 13 '16 at 02:26