Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Fortunately I think it's not possible to just send an e-mail in the name of someone else (using someone else's credentials).</p> <ol> <li>As @DGibbs shows, you'd need to know the credentials of the particular user. But you don't have the password.</li> <li>The SMTP protocol alone wouldn't prevent you to use any kind of sender e-mail address in the "From" field, but the .NET <code>SmtpClient</code> will throw an exception (<code>SmtpException</code> <a href="http://msdn.microsoft.com/en-us/library/swas0fwc.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/swas0fwc.aspx</a>).</li> <li>The <code>SmtpClient</code> actually will only willing to send the e-mail if the running software's (or provided by NetworkCredentials) credentials match the from address's user.</li> <li>If you use <code>UseDefaultCredentials</code>, the credentials (of the default) should still match the e-mail address's user and should be authorized.</li> <li>What you can do is to setup a mail account for the purpose of automated mail. Even in this case there's a good chance that the software will run in the name of some other user, so system administrator has to configure that automated mail account in the mail server so that it would willing to let the software's user to send in the name of the automated account. The automated mail's subject or body can reference the user's name and e-mail if you like.</li> </ol> <p>All of this is because today there are lot of mechanisms exist to prevent spamming. The system prevents you even from yourself to do anything which wouldn't be a good idea. Sending an e-mail in whoever's name is not a good idea from security point of view, even if the business requirements would require it.</p> <p><code>System.Net.Mail</code> provides a very clean and nice interface and API, but you have to work around the usage what you want. I've been there, done that. I mean the same situation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload