SMTPMAIL

A

aslantifosi

hi all,
My question is about that i use a smpt server which is running on a
different machine from my webserver machine. And i can authenticate with a
user and password. I use SmtpMail class. i set the smtpserver property. but
how can i authenticate with my user and pass?

for ex:
my user :[email protected]
pass :12345

Message.From = myuser;
Message.To=strTo;

Message.Subject=strSubject;

Message.Body = strBody;

try

{

SmtpMail.SmtpServer = "172.19.1.123";

SmtpMail.Send(Message);

}

catch(System.Web.HttpException ehttp)

{



}
 
J

Juan T. Llibre

As you can see, there's no classes in system.web.mail
which allow for sender authentication :

..Net Framework 1.1 :
http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

..Net Framework 2.0 :
http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

However, you can *add the authentication schemas* :

private void Page_Load(object sender, System.EventArgs e)
{

MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
mail.Subject = "this is the subject.";
mail.Body = "this is the body";

//add schema for basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
// if you want NTLM authentication, use "2" !

//set the username
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

//set the password
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

//your mail server's name goes here
SmtpMail.SmtpServer = "mail.server.com";

// finally, send the user-authenticated mail
SmtpMail.Send(mail);
}

---000---

Check it out, and let me know if that works for you.
 
A

aslantifosi

Thanks a lot.
Bu i can't test immediately. After the test, i'll return a message to group.
As you can see, there's no classes in system.web.mail
which allow for sender authentication :

.Net Framework 1.1 :
http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

.Net Framework 2.0 :
http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

However, you can *add the authentication schemas* :

private void Page_Load(object sender, System.EventArgs e)
{

MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
mail.Subject = "this is the subject.";
mail.Body = "this is the body";

//add schema for basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
// if you want NTLM authentication, use "2" !

//set the username
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

//set the password
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

//your mail server's name goes here
SmtpMail.SmtpServer = "mail.server.com";

// finally, send the user-authenticated mail
SmtpMail.Send(mail);
}

---000---

Check it out, and let me know if that works for you.
 
F

Frankie

I can verify that your suggestion works. I've had it going for several months with no problems.

-Frankie


As you can see, there's no classes in system.web.mail
which allow for sender authentication :

.Net Framework 1.1 :
http://www.csharpfriends.com/quicks...b/classbrowser.aspx?namespace=System.Web.Mail

.Net Framework 2.0 :
http://beta.asp.net/quickstart/util/classbrowser.aspx?namespace=System.Web.Mail

However, you can *add the authentication schemas* :

private void Page_Load(object sender, System.EventArgs e)
{

MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
mail.Subject = "this is the subject.";
mail.Body = "this is the body";

//add schema for basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
// if you want NTLM authentication, use "2" !

//set the username
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "the_username");

//set the password
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "the_password");

//your mail server's name goes here
SmtpMail.SmtpServer = "mail.server.com";

// finally, send the user-authenticated mail
SmtpMail.Send(mail);
}

---000---

Check it out, and let me know if that works for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top