I have been fighting with this for some time now and I feel that I have to be missing something simple....
Basically, I set up a LAN based email server (CMailServer) on another box for development / testing purposes. Under the options in cMailServer...I have enabled ESMTP (Authentication)
I then set up the email account in Microsoft Outlook and under advance have it set to authenticate outgoing email.
I am then able to run a test (Send and receive) succesfully in MS outlook...
I then run my code (C#) and attempt to send an email ....If I have authentication on the cMailServer turned off...the email from c# will send successfully.... how ever if I have authentication on the cMailServer turned on I am unable to send a successfully email even though I am using the appropriate credentials....
Here is the code and settings I am using to send an email:
- On the C# box...I have set the host file to point to (cMailServer IP Address) to r1qe.com...
- this.HTMLSupported = true
- this.OutGoingSerReqAuth = true
- this.SMTPMailServer = r1qe.com.
- this.SMTPMailPort = 25
- this.SSLRequired = false;
Any help with this will certainly be appreciated...
NetworkCredential basicCredentials = new NetworkCredential(this.MailUserName, this.MailPassword);
MailMessage mail = new MailMessage();
mail.IsBodyHtml = this.HTMLSupported;
mail.From = new MailAddress("email@example.com", "Critical " + (char)0xD8 + " Results", System.Text.Encoding.UTF8); // put the from address here
mail.To.Add(new MailAddress("firstname.lastname@example.org")); // put to address here
mail.ReplyTo = (new MailAddress("email@example.com")); // put reply to address here
mail.Subject = "email test"; // put subject here
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "test of email sender"; // put body of email here
mail.BodyEncoding = System.Text.Encoding.UTF8;
//Set Up Outgoing smtp requires authentication support
SmtpClient wClient = new SmtpClient(this.SMTPMailServer, this.SMTPMailPort);
wClient.Timeout = this.MailServerTimeouts;
wClient.EnableSsl = this.SSLRequired;
if (this.OutGoingSerReqAuth == true)
wClient.UseDefaultCredentials = false;
wClient.Credentials = basicCredentials;
wClient.UseDefaultCredentials = true;