473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

StmpClient does not seems to use NetworkCredential

Guy
I use SmtpClient to send mail. My customer reported that sending mail
was throwing an exception on his machine "the SMPT client requires a
secure connection or the client was not authenticated".

so I now provide credentials with my request, however it sends mail
all the time, whichever username or password I use. I even removed the
password from my Outlook account options. Sends mail anyway ?

Is there a credential cache in Windows taking effect ?

cred = new NetworkCredential(strUserName, strPassword);

smtp = new SmtpClient();
smtp.Host = strMailHost;
smtp.UseDefaultCredentials = false;
smtp.Credentials = cred;

May 27 '07 #1
1 7599
Probably TLS/SSL needed:

string from = "me@example.com";
string to = "yo*@example.com";
string username = "username";
string password = "password";

System.Net.Mail.MailMessage email = new
System.Net.Mail.MailMessage(from, to);
email.Body = "Hi";
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient();
System.Net.NetworkCredential basicAuthenticationInfo = new
System.Net.NetworkCredential(username, password);
mailClient.Host = "smtp.example.com";
mailClient.Port = 587; //preferred port for sending SMTP
messages (if it doesn't work just remove this line)
mailClient.EnableSsl = true; //!!!!!important!!!!!!!!
mailClient.UseDefaultCredentials = true;
mailClient.Credentials = basicAuthenticationInfo;
mailClient.Send(email);

Miroslav Stampar MCSD, Security+
http://mstampar.awardspace.com

Guy je napisao/la:
I use SmtpClient to send mail. My customer reported that sending mail
was throwing an exception on his machine "the SMPT client requires a
secure connection or the client was not authenticated".

so I now provide credentials with my request, however it sends mail
all the time, whichever username or password I use. I even removed the
password from my Outlook account options. Sends mail anyway ?

Is there a credential cache in Windows taking effect ?

cred = new NetworkCredential(strUserName, strPassword);

smtp = new SmtpClient();
smtp.Host = strMailHost;
smtp.UseDefaultCredentials = false;
smtp.Credentials = cred;
May 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eddie Lipshultz | last post by:
I'm working with the NetworkCredential class. I'm making the correct call and it returns that everything is okay using: NetworkCredential sc = new NetworkCredential("MyAccount", sPassword,...
2
by: Prathiraj | last post by:
Hi All, I'm trying to access a web page from C# code. Since I'm behind a firewall/proxy, I creat a webproxy and NetworkCredential to access the web page. It works fine. In this way, I have to...
0
by: Ivan G. | last post by:
Hi. I'm trying to call web service passing a new System.Net.NetworkCredential to it's reference: jobs.Jobs j = new jobs.Jobs(); j.Credentials = new...
3
by: Justin Dutoit | last post by:
Hey. I have the error CS0117 'BusinessLayer' does not contain a definition for 'MySoapHeader'. Below is a link to the asmx source, and the code which calls the web service. MS seems to do the same...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
0
by: steve | last post by:
Hi We have an application that send webRequests to a server using a specified user accounts. These requests will often be for different users. The problem we have is that the webRequest, even...
2
by: YK | last post by:
Hi I have a Web Application that connects to Exchange WebDAV using a class that I found on http://www.codeproject.com/dotnet/exdav.asp. This class requires a NetworkCredential object in order to...
1
by: dlutz | last post by:
Hello to all -- I am familiar with Xml in general and NET 1.1 Xml, but I am new to the ..NET 2.0 changes in System.Xml. I am trying to validate an XML document that is based on a schema that...
3
by: antonyliu2002 | last post by:
I have a website (call it WinAuthWeb) that uses Integrated Windows Authentication. In my ASP.NET web application, I collect user name, password and domain info and pass them to WinAuthWeb for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.