Reputation: 5902
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("[email protected]","mypassword");
MailMessage msg = new MailMessage();
sg.From = new MailAddress("[email protected]");
msg.To.Add(new MailAddress("[email protected]"));
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:[email protected]" but actually it is coming from "[email protected]"
Note: We are obliged by SMTP Server setting to enter the password in the Network Credentials
Thanks
Upvotes: 1
Views: 239
Reputation: 175826
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.
Upvotes: 1