Hello,
I want to send authenticated emails from within my web application to prevent them to be delivered into the recipient's "Junk" folders.
I tried this code:
private static void send_authenticated(MailMessage msg) { try { SmtpClient cli = new SmtpClient(cfg_Server); cli.DeliveryMethod = SmtpDeliveryMethod.Network; cli.EnableSsl = false; cli.UseDefaultCredentials = false; cli.Credentials = new NetworkCredential("myUser", ""); cli.Send(msg); txt_Status = "OK"; } catch (SmtpException exc) { txt_Status = exc.Message; txt_Status += "\n" + exc.Source + "\n" + exc.StackTrace; } catch (Exception exc) { txt_Status = exc.Message; } }
There is a username "myUser" and an empty password. The username is the name of a group mail address, which has no password.
Well, the email arrives at the recipient. Then, I changed "myUser" to something that doesn't exist, and the mail also arrives.
Because of this behavior, I believe that there is no authentication at all?
What am I doing wrong?
Thanks
Magnus