GMAail smtp无法在另一台PC上运行

时间:2018-08-03 08:37:46

标签: c# .net winforms gmail smtpclient

当我尝试在应用程序中调用此方法时遇到问题。 当应用程序在我的PC上(写此代码的地方)时,它可以工作,但是当我将应用程序发送到另一台客户端(PC)时,它不再起作用。

我尝试将每个端口(465,587,25,2525)连接到更多PC。 我认为与smtp服务器的连接有问题。

您知道为什么它不能在另一台PC上运行吗?

private void materialFlatButton1_Click(object sender, EventArgs e)
    {
        if (indexfeedback == 0)
        {
            var fromAddress = new MailAddress("xxxxxxxx@gmail.com");
            var toAddress = new MailAddress("xxxxxxxxxx@gmail.com");
            const string fromPassword = "password";
            const string subject = "Subject";
            const string body = "Body";

            var smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };
            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
                label444.Text = "SEND !!!";
            }


            indexfeedback++;
        }
        else
        {
            label234.Visible = true;
        }
    }

感谢您的帮助! 我在办公室尝试了2个小时以寻找解决方案,但没有找到任何东西

0 个答案:

没有答案
相关问题