これが特に MvcMailer の質問だとは思いませんが (これは私が使用しているメーラーです)、Googleplex 検索を構成して、コンテキストに基づいてさまざまなアカウントから電子メールを送信する方法を見つけるのに苦労しています。
2 つの異なる電子メール アカウントから 2 つの電子メールを送信する必要があります。使ってみました
mailMessage.From = new MailAddress("some-other-email@gmail.com");
MvcMailer では、一時ディレクトリにダンプした電子メールにも表示されません。web.config にあるものとして表示されます: "some-email@gmail.com"。
これは、MvcMailer の web.config です。
<mailSettings>
<!-- Method#1: Configure smtp server credentials -->
<!--<smtp from="some-email@gmail.com">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="some-email@gmail.com" password="valid-password" />
</smtp>-->
<!-- Method#2: Dump emails to a local directory -->
<smtp from="some-email@gmail.com" deliveryMethod="SpecifiedPickupDirectory">
<network host="localhost" />
<specifiedPickupDirectory pickupDirectoryLocation="c:\temp\" />
</smtp>
</mailSettings>
これはメーラーコードです:
public virtual MailMessage EMailConsultation(EMailConsultationData model)
{
var mailMessage = new MailMessage { Subject = "INQUIRY: E-Mail Consultation" };
mailMessage.From = new MailAddress("some-other-email@gmail.com");//I tested this to see if at the very least it would show up in the e-mail, but it didn't.
mailMessage.To.Add(model.EMail);
ViewData = new ViewDataDictionary(model);
PopulateBody(mailMessage, viewName: "InquiryEMailConsultation");
return mailMessage;
}
繰り返しますが、上記のコードは電子メールを送信するために機能します。web.configのように「some-email@gmail.com」からではなく、指定した電子メールアドレスから送信するようにメーラーを設定する方法がわかりません。複数の MailMessage があり、別の電子メール アカウントから特定のメッセージを送信する必要があります。
ヘルプ/コード例をいただければ幸いです。