My Exchange server needs authentication to send mails. Later found that .NET 1.0 doenst support authencation with an SMTP server. I had to switch over to .NET 1.1 to send mails. All which is required to add a few lines of code for authentication.
//This is a usual code
System.Web.Mail.MailMessage msg =
"Sample Body Message"
System.Web.Mail.SmtpMail.Send( msg );
//Add this line of code for authentication.
Where the 2 specifies NTLM, 1 for basic, 0 for none.
Some comments from the original post on WWWCoder.com:
I use Brinkster.com as my web/mail hosting service and GoDaddy as my domain name registrar. The smtp server and auth. info to use is NOT the same info you use to login to their respective site, but rather the smtp server specified in their faq and the email address you've set up in their email manager. Brinkster's is sendmail.brinkster.com. This is different than the one you use for your email account. However, the authentication IS the info from your email account (if they host your mail, too). In short, for Brinkster, I use sendmail.brinkster.com as my smtp server, and [email protected] as the username, and the password I use (to check email on this account) as the password.
Hope this helps..I know it's confusing..just got to read the faqs on your respective provider's site because it's usually a freaky combination such as this to get it to work..but it will work. I created a simple web service that accepts all info as parameters and returns a string either stating "success" or the actual exception caught when trying to send email (so can read whether or not connection was made, or auth. was bad, etc.). This service is written in C#, but it works like a charm!
If you don't need to authenticate, leave the last 3 parameters blank (just send empty strings), else fill in w/ your smtp server and login info.
"Simple mailer w/ authentication"
MailMessage mm =
mm.From = mailfrom;
mm.To = mailto;
mm.Subject = mailsubject;
mm.Body = mailbody;
mm.Cc = mailcc;
mm.Bcc = mailbcc;
mm.BodyFormat = MailFormat.Text;
cdoBasic = 1;
cdoSendUsingPort = 2;
_results = e.ToString();
Just in case anybody was wondering how to authenticate it .net <B>1.0</B> (it took me a while) this works.
ObjSendMail = CreateObject(
iConf = CreateObject(
Flds = iConf.Fields
ObjSendMail.Configuration = iConf
ObjSendMail.From = SentBy
ObjSendMail.Subject = Subject
ObjSendMail.HTMLBody = Message
ObjSendMail.TextBody = Message
Nothing new, its just using CDO, but its new to me. I've been using web.mail for a while, but I've got .Net 1.0 and all the sudden my host started requiring users to authenticate, so this is what I found.