0

gmailD を使用してメールを送信すると、次のエラー メッセージが表示されます。

SMTP サーバーが安全な接続を必要としているか、クライアントが認証されていません。サーバーの応答は次のとおりです。5.5.1 認証が必要です。

MailMessage objMailMessage = new MailMessage();
        objMailMessage.From = new MailAddress("suraj.podval@in.vsolutions.com");
        objMailMessage.To.Add(new MailAddress("itslaxman@gmail.com"));
        objMailMessage.Subject = "Test";
        objMailMessage.Body = "Test Test";
        objMailMessage.IsBodyHtml = true;

        SmtpClient smtpClient = new SmtpClient();
        smtpClient.Host = "smtp.gmail.com";
        smtpClient.Port = 587;           
        smtpClient.EnableSsl = true;
        smtpClient.UseDefaultCredentials = false;         
        smtpClient.Credentials = new System.Net.NetworkCredential("user@gmail.com", "password");
        smtpClient.Send(objMailMessage);
4

1 に答える 1

0

ポートを 465 に変更してみてください

            SmtpMail oMail = new SmtpMail("TryIt");
            SmtpClient oSmtp = new SmtpClient();

            // Your gmail email address
            oMail.From = "gmailid@gmail.com";

            // Set recipient email address
            oMail.To = "support@emailarchitect.net";

            // Set email subject
            oMail.Subject = "test email from gmail account";

            // Set email body
            oMail.TextBody = "this is a test email sent from c# project with gmail.";

            // Gmail SMTP server address
            SmtpServer oServer = new SmtpServer("smtp.gmail.com");

            // If you want to use direct SSL 465 port, 
            // please add this line, otherwise TLS will be used.
            // oServer.Port = 465;

            // detect SSL/TLS automatically
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

            // Gmail user authentication
            // For example: your email is "gmailid@gmail.com", then the user should be the same
            oServer.User = "gmailid@gmail.com";
            oServer.Password = "yourpassword";

以下のリンクを確認してください: http://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=2

于 2012-04-11T05:52:28.900 に答える