C# SMTP authentication failed but credentials are correct

后端 未结 3 1318
清歌不尽
清歌不尽 2021-01-28 03:20

Here is my problem: I wrote whe following program to test if I can send email:

class Program
{
    static void Main(string[] args)
    {
        try {
                   


        
3条回答
  •  粉色の甜心
    2021-01-28 03:45

    For anyone interested. I had a problem t=with this today. and found my solution was the order.

    SMTPClient client = new SMTPClient();
    client.UseDefaultCredentials = false; // first after declare and needs to be false.
    

    Then:

    client.Credentials = new System.Net.NetworkCredential(sMTPSettings.SMTPLogin, sMTPSettings.SMTPPassword);
    

    Then the rest.

    Hope it helps someone

提交回复
热议问题