0

I'm developing a simple send mail app in C#, using my CMail Server:

MailMessage mail = new MailMessage("from@mail.com", "destination@mail.com");
        mail.Subject = "Sub";
        mail.Body = "Hi!";
        SmtpClient smtp = new SmtpClient("MyServer");
        System.Net.NetworkCredential cred = new System.Net.NetworkCredential("user", "pass");
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = cred;
        smtp.Send(mail);

Obviously i ommited my account information, so, this code throws me an Authentication Exception for some reason. I first thought that the code was wrong, so i change the info to my gmail account and everything goes fine, with the only SMTP server that i having trouble is with the CMail. Is there a problem with .NET and CMail's SMTP ?

Thanks for the help and comments!

4

3 に答える 3

0

Try adding:

smtp.EnableSsl = true;
于 2010-05-03T20:48:20.863 に答える
0

2 段階認証を使用している場合は、アプリケーション固有のパスワードを追加する必要があります。

于 2013-04-26T01:20:32.213 に答える