开发者

Sending Email from SMTP server from a certain email, but make it appear as if coming from another email

开发者 https://www.devze.com 2023-04-09 13:57 出处:网络
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("smtp.mydomain.com");
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = loginInfo;
client.Send(msg);

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? That is only change the "From" field, to make the email look like : "From:aa@mydomain.com" but actually it is coming from "bb@mydomain.com"

Note: We are obliged by SMTP Server setting t开发者_如何学Co enter the password in the Network Credentials

Thanks


You can set it to whatever you like; if its being rejected its a decision that was made by the smtp server based on its security configuration - thats where you will need to make a change, not in your client code.

0

精彩评论

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

关注公众号