有没有办法使用ASP.NET通过谷歌企业应用套件acccount发送电子邮件而不选择“允许安全性较低的应用程序”选项的方法吗? [英] Is there a way to use ASP.NET to send email through a Google Apps acccount without selecting the 'Allow less secure apps' option?

查看:1172
本文介绍了有没有办法使用ASP.NET通过谷歌企业应用套件acccount发送电子邮件而不选择“允许安全性较低的应用程序”选项的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我试图用发送电子邮件的的ASP.NET Web API。我越来越用smtp.gmail.com和587.我见过几个环节说来打开我的谷歌Apps帐户的允许安全性较低的应用程序选项认证的问题,但我宁愿没有解释给业主他们为什么要挑这个可疑的冠冕堂皇的设置。

有没有办法来包装ASP.NET中的电子邮件请求,谷歌会喜欢,否则我将不得不选择允许安全性较低的应用程序选项?

这是code我使用的谷歌不喜欢。

 使用(VAR的客户=新SmtpClient(smtp.googlemail.com,587))
{
    client.Credentials =
        新System.Net.NetworkCredential(address@yourdomain.com,你的密码);
    client.EnableSsl = TRUE;
    VAR味精= MAILMESSAGE新(address@yourdomain.com,toaddress@anotherdomain.com);
    msg.Body =[邮件体HERE];
    msg.Subject =[邮件主题];    client.Send(MSG);
}


解决方案

谷歌改变了前一段时间(一年或两年以前)可能使用它的SMTP服务器。谷歌现在需要的安全和认证的更高的水平。
但是仍然有使用它没有'允许安全性较低的应用程序选项可能,但你不能用你的标准谷歌的用户名和密码。

下面是如何做到这一点(简称):


  

      
  1. 在您的Gmail两步验证打开或Google Apps帐户中的我的帐户/登录与放大器;安全,

  2.   
  3. 然后(在我的帐户/登入与安全性/应用程序密码),它可以生成从其他应用程序访问一个特殊的密码(不开启两步骤验证你不能有)

  4.   
  5. 此创建应用程序密码(和你的谷歌电子邮件帐户作为用户名),那么你可以为你的SMTP登录使用。

  6.   

这就是全部。

I have an ASP.NET web API that I'm trying to use to send an email. I'm getting authentication issues using smtp.gmail.com and 587. I've seen several links saying to toggle the 'Allow less secure apps' option on my Google Apps account, but I'd rather not have to explain to the owners why they need to pick this dubious-sounding setting.

Is there a way to package an email request in ASP.NET that Google will like, or will I have to select the 'Allow less secure apps' option?

This is the code I'm using that Google doesn't like.

using (var client = new SmtpClient("smtp.googlemail.com", 587))
{
    client.Credentials = 
        new System.Net.NetworkCredential("address@yourdomain.com", "yourpassword");
    client.EnableSsl = true;
    var msg = new MailMessage("address@yourdomain.com", "toaddress@anotherdomain.com");
    msg.Body = "[YOUR EMAIL BODY HERE]";
    msg.Subject = "[Message Subject]";

    client.Send(msg);
}

解决方案

Google changed some time ago (one or two years ago) possibility to use its SMTP servers. Google now requires higher level of security and authentication. However there still is a possibility to use it without 'Allow less secure apps' option, but you cannot use your standard google username and password.

Here is how to do it (in short):

  1. Turn on 2-Step Verification in your gmail or google apps account in "My account / Sign-in & security",
  2. then (in "My account / Sign-in & security / App passwords") it is possible to generate a special password for access from other applications (without turned on 2-Step Verification you can not get there)
  3. this created app password (and your google e-mail account as a username) you can then use as your SMTP login.

That's all.

这篇关于有没有办法使用ASP.NET通过谷歌企业应用套件acccount发送电子邮件而不选择“允许安全性较低的应用程序”选项的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆