私は自分の SMTP サーバーを構築している C# プロジェクトに取り組んでいます。基本的には機能していますが、複数の受信者を送信しようとしていますが、エラーが発生しています。
送信者ドメインから MX レコードを取得し、MX レコードを使用して複数の受信者に電子メールを送信しようとしています。同じドメインで 2 人の受信者を処理すると正常に動作しますが、2 人の受信者が異なるドメインを持っている場合は、次の応答が返されます。
Failed to send email. General Exception: Error in processing. The server response was: 4.3.0 Multiple destination domains per transaction is unsupported. Please
それ以降は何もなくplease
、応答が終了します。
以下は、MX レコードを取得する方法です。
string[] mxRecords = mxLookup.getMXRecords(Classes.CommonTasks.getDomainFromEmail(ドメイン));
public string[] getMXRecords(string domain)
{
DnsLite dl = new DnsLite(library);
ArrayList dnsServers = getDnsServers();
dl.setDnsServers(dnsServers);
ArrayList results = null;
string[] retVal = null;
results = dl.getMXRecords(domain);
if (results != null)
{
retVal = new string[results.Count];
int counter = 0;
foreach (MXRecord mx in results)
{
retVal[counter] = mx.exchange.ToString();
counter++;
}
}
return retVal;
}
以下は、私がメールを送信する方法です。
if (mxRecords != null)
{
MailMessage composedMail = new MailMessage();
composedMail.From = new MailAddress(message.EmailFromAddress);
//MailAddressCollection test = new MailAddressCollection();
//composedMail.To = test;
composedMail = addRecipientsToEmail(composedMail, message.emailRecipients);
composedMail.Subject = message.subject;
composedMail.Body = message.EmailBody;
if (message.contentType.ToString().Contains("text/html"))
{
composedMail.IsBodyHtml = true;
}
SmtpClient smtp = new SmtpClient(mxRecords[0]);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Port = 25;
if (Configuration.emailConfig.useSmtpMaxIdleTime)
{
smtp.ServicePoint.MaxIdleTime = 1;
}
library.logging(methodInfo, string.Format("Sending email via MX Record: {0}", mxRecords[0]));
smtp.Send(composedMail);
updateEmailStatus(message.emailID, EmailStatus.Sent);
library.logging(methodInfo, string.Format("Successfully sent email ID: {0}", message.emailID));
}
else
{
string error = string.Format("No MX Record found for domain: {0}", domain);
library.logging(methodInfo, error);
library.setAlarm(error, CommonTasks.AlarmStatus.Warning, methodInfo);
}
これは、Google が実行を制限しているように見えますが、受信者ごとにメールを個別に送信する以外に回避する方法が見つかりません。
用途がある場合、2 つのドメインは Google アプリ ドメインです。
ご協力いただきありがとうございます。