Solved

System.Web.Mail class - please explain...

Posted on 2007-03-28
4
181 Views
Last Modified: 2010-04-16
Ok i am having a few issues with some STMP code we have in production. I have narrowed these issues down to (among other things) McAfee...

Anywho..... that is not what i am posting about...

As i am testing, when i disable McAfee and directly connect to the exchange server like so:

--------------------------------------------------------------------------------------------------------------------------
public static void SendMail(string from, string recipients, string subject, string body)
{
MailMessage mail = new MailMessage();
mail.To = recipients;
mail.From = from;
mail.Subject = subject;
mail.Body = body;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); SmtpMail.SmtpServer = "XX.XX.XX.XXX";
SmtpMail.Send(mail);
}
--------------------------------------------------------------------------------------------------------------------------

... my email gets set and all is good...

My issue is that most of the mail code in production do NOT use this class and instead (i guess) uses default setting. Here is the code in production:

--------------------------------------------------------------------------------------------------------------------------
MailMessage mail = new MailMessage();
mail.To = "you@you.com";
mail.From = "me@me.com";
mail.Subject = "Mail Subject"
mail.Body = "Mail body"
SmtpMail.Send(mail);
--------------------------------------------------------------------------------------------------------------------------

This i assume uses the default SMTp server setup on the local web server that it is running from... Right?

If that is the case then why is it that when i stop the IIS SMTP server this code still sends out mail... What SMTP server is it using to send the mail if the local is disabled?

To clarify, what i need to knwo is what is the default for the mail class when no SMTP server is specified.

:: Nugs ::
0
Comment
Question by:Nugs
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
volking earned 500 total points
ID: 18810769
I believe Active Directory keeps an SMTP routing stack. If the top server dies (or goes away) Active directory will return the next SMTP Server in the stack. Actually, I'm not sure how this works, but you may want to begin looking at Active Directory.
0
 
LVL 2

Author Comment

by:Nugs
ID: 18810821
This makes sense as i i have old legacy code on the webserver that is NOT specifying a SMTP server and has (supposibly) worked in the past... What is boggling me is that there is no local SMTP server setup on the web server - by design. I can not see how this old code ever worked without one there or directly specifying the Exchange server in the code.

:: Nugs ::
0
 
LVL 2

Author Comment

by:Nugs
ID: 18810847
Oh i was just informed that the web server is not even on the same subnet as our network (it has an external IP obviousley) so it can not be finding the Esxchange server via AD...

:: Nugs ::
0
 
LVL 2

Author Comment

by:Nugs
ID: 18812415
It was using my localhost SMTp, apparently stoping the SMTP server in IIS does not stop the SMTP service. Stopping the service stoped outbound mail.

Interesting about the AD stuff thought, thanks for your input.

:: Nugs ::
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Service Controller 1 23
What can cause the styling on a .NET site to not be found? 17 25
Hey!!!! 1 21
Winforms -- Capture CTRL+SHIFT+D at the form not working? 3 22
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question