开发者

Sending email from SMTP server without the need to enter password

开发者 https://www.devze.com 2023-04-06 16:24 出处:网络
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 ma

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("sm开发者_高级运维tp.mydomain.com");
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = loginInfo;
client.Send(msg);

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?

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号