在ASP.NET中发送无密码的电子邮件 [英] Send email without password in ASP.NET
本文介绍了在ASP.NET中发送无密码的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
您能否给我解决方案如何在asp.net中发送电子邮件而不使用密码在asp.net c#。
请给我>
我尝试过:
Hello,
Can you give me solutions for how to send email in asp.net without using password in asp.net c#.
Please give me
What I have tried:
string to = "adhikar.patil@gmail.com";
string from = "adhikar.patil@gmail.com";
MailMessage message = new MailMessage(from, to);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<table>");
sb.AppendFormat("<tr><td>Name:</td><td>{0}</td></tr>", txtName.Text.Trim());
sb.AppendFormat("<tr><td>Email:</td><td>{0}</td></tr>", txtEmail.Text.Trim());
sb.AppendFormat("<tr><td>Phone No</td><td>{0}</td></tr>", txtPhoneNo.Text.Trim());
sb.AppendFormat("<tr><td>Organisation:</td><td>{0}</td></tr>", txtOrganisation.Text.Trim());
sb.Append("<table>");
message.Subject = "BDS Contacted by " + txtName.Text;
message.Body = sb.ToString();
//message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
System.Net.NetworkCredential basicCredential1 = new
System.Net.NetworkCredential("abc@gmail.com", "abc");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
try
{
client.Send(message);
}
catch (Exception ex)
{
throw ex;
}
推荐答案
基本上,你不能,除非你的电子邮件服务被配置为不需要一个 - 那就是非常罕见。大多数系统都设置为需要密码(可能只需要输入一次您的读/写器应用程序),然后才会发送电子邮件以确保安全:防止我伪装成您;并防止垃圾邮件发送者和网络钓鱼者通过流氓或木马应用程序使用您的帐户。
查看您的电子邮件服务,看看他们说了什么 - 如果他们不允许它,你不能这样做。
Basically, you can't, unless your email service is configured to not need one - and that's is incredibly rare. Most systems are set up to require a password (which may only have to be entered to your reader / writer app once) before they will send an email for security: to prevent me pretending to be you; and to prevent spammers and phishers from using your account via rogue or trojan apps.
Check with your email service, and see what they say - if they don't permit it, then you can't do it.
使用你的网络主机提供的SMTP服务器。
您不应该花时间做的事情 - 通过Gmail发送电子邮件 [ ^ ]
Use the SMTP server provided by your web host.
Things you shouldn't spend time doing - Sending email via Gmail[^]
这篇关于在ASP.NET中发送无密码的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文