SMTP电子邮件不起作用,5.7.1客户端作为发件人没有发送的权限

时间:2021-09-14 18:11:28

Morning, I cant understand why this code dont works! thanks, waiting awnsers :)

早上好,我不明白为什么这个代码不能工作!谢谢,等待awnsers:)

protected void Enviar_Click(object sender, EventArgs e)
    {


        var pass = new NetworkCredential();
        pass.UserName = "myuser@gmail.com";
        pass.Password = "password";


        var smtpClient = new SmtpClient();

        smtpClient.Port = 587;
        smtpClient.Host = "smtp.gmail.com";
        smtpClient.Credentials = pass;
        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtpClient.EnableSsl = true;
        smtpClient.UseDefaultCredentials = false;


        var email = new MailMessage(pass.UserName, "myname@mywork.com.br", txtsubject.Text,
                                    "name   :  " + txtname.Text + "menssage  : " + txtMessage.Text);

        SMTP.Enviar(email);
    }

1 个解决方案

#1


0  

Look like you need to enable pop3 in your gmail account - Check out Gmail's help section on POP access for Gmail for specific instructions for setting this up with your email program. If you only want to use the SMTP server, skip the POP bits and only set up SMTP to work with your existing email account.

看起来您需要在gmail帐户中启用pop3 -查看gmail关于gmail POP access的帮助部分,了解如何在您的电子邮件程序中设置pop3。如果您只想使用SMTP服务器,那么跳过POP位,只设置SMTP来使用现有的电子邮件帐户。

#1


0  

Look like you need to enable pop3 in your gmail account - Check out Gmail's help section on POP access for Gmail for specific instructions for setting this up with your email program. If you only want to use the SMTP server, skip the POP bits and only set up SMTP to work with your existing email account.

看起来您需要在gmail帐户中启用pop3 -查看gmail关于gmail POP access的帮助部分,了解如何在您的电子邮件程序中设置pop3。如果您只想使用SMTP服务器,那么跳过POP位,只设置SMTP来使用现有的电子邮件帐户。