从SMTP服务器发送电子邮件,无需输入密码 [英] Sending email from SMTP server without the need to enter password

查看:274
本文介绍了从SMTP服务器发送电子邮件,无需输入密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个应用程序,提示用户使用其ldap用户名和密码登录,从中我可以获取用户电子邮件,但不能获取电子邮件密码.我的目标是从该用户的邮件中发送电子邮件,而无需提示用户输入电子邮件密码.

We have an application that prompts the user to login using his ldap username and password, from that I can get the user email but not the email password, My goal is to send email from this user's mail without the need to prompt the user for his email password.

我正在使用以下代码发送电子邮件

I am using the following code to send email

NetworkCredential loginInfo = new NetworkCredential("fromemail@mydomain.com","mypassword");
MailMessage msg = new MailMessage();
sg.From = new MailAddress("fromemail.lb@mydomain.com");
msg.To.Add(new MailAddress("toemail.lb@mydomain.com"));
msg.Subject = "test";

SmtpClient client = new SmtpClient("smtp.mydomain.com");
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = loginInfo;
client.Send(msg);

可以发送不带密码的电子邮件吗?诸如电子邮件欺骗之类的东西,如果不是possilbe,是否有可能伪造它,例如以一封电子邮件形式发送所有电子邮件,但使该电子邮件看起来像是来自已登录用户的电子邮件呢?

IS is is possible to send email without password? some thing like email spoofing, If not possilbe, is it possible to fake it, like send all emails form one email, but make the email look as if it is coming from the logged in user's email?

谢谢

推荐答案

这全部取决于SMTP服务器.在配置SMTP服务器时,您需要确定它接受什么凭据以及是否允许您假装自己不是别人.许多Web服务器在本地主机上都具有内置的SMTP服务器,该服务器通常不需要任何凭据.某些ISP提供了一个SMTP服务器,使您可以从其他人发送电子邮件.如果您的SMTP服务器不需要身份验证,则只需删除3行代码即可为smtp客户端配置安全性.

It all depends on the SMTP server. When you configure the SMTP server you decide what credentials it accepts and whether it allows you to pretend to be someone you're not. Many web-servers have a built in SMTP server at localhost which usually doesn't require any credentials. Some ISPs provide an SMTP server which allows you to send email from other people. If your SMTP server does not require authentication you can simply remove the 3 lines of code which configure security for the smtp client.

这篇关于从SMTP服务器发送电子邮件,无需输入密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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