title: Is it possible to have a different sender email and configuration email to send email from MimeKit in ASP.Net Core?
body: <p>I have added code which will send emails to the receiving party. As of now I need to add the same email address in &quot;from&quot; email and &quot;username&quot;(config email) to send the email else it will fail. But I wish to have different &quot;from&quot; email and not asking users for password and using one config mail to send email so multiple users can consume this service to send emails. Is it possible to do so?</p>
  <p>Here is my code:</p>
  <pre class="lang-cs prettyprint-override"><code>public async Task&lt;string&gt; Send(string from, string to, string subject, string html, string userName, string password)
  {
      // create message
      var email = new MimeMessage();
      email.From.Add(MailboxAddress.Parse(from));
      email.To.Add(MailboxAddress.Parse(to));
      email.Subject = subject;
      email.Body = new TextPart(TextFormat.Html) { Text = html };
      using var smtp = new SmtpClient();
      smtp.Connect(&quot;smtp.live.com&quot;, 587, SecureSocketOptions.StartTls);
      smtp.Authenticate(userName, password);
      smtp.Send(email);
      smtp.Disconnect(true);
      return &quot;Email Set&quot;;
  }
  </code></pre>