Asp.net c# サイトからメールを送信する必要があります。ovh でホストしています。
public static void Send(string stringFrom, string stringFromPass,
string stringTo, string stringBody, string stringSubject, int tryNb)
{
// Command line argument must the the SMTP host.
SmtpClient client = new SmtpClient("smtp.mondomaine.me", 587);
// Specify the e-mail sender.
// Create a mailing address that includes a UTF8 character
// in the display name.
MailAddress from = new MailAddress(stringFrom,
"Sender",
System.Text.Encoding.UTF8);
// Set destinations for the e-mail message.
MailAddress to = new MailAddress(stringTo);
// Specify the message content.
MailMessage message = new MailMessage(from, to);
message.Body = stringBody;
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = stringSubject;
message.SubjectEncoding = System.Text.Encoding.UTF8;
//provide Authentication Details need to be passed when sending email from gmail
string password = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(stringFromPass));
NetworkCredential mailAuthentication = new NetworkCredential(stringFrom, password);
client.UseDefaultCredentials = false;
client.Credentials = mailAuthentication;
// Set the method that is called back when the send operation ends.
client.SendCompleted += new
SendCompletedEventHandler(SendCompletedCallback);
// The userState can be any object that allows your callback
// method to identify this send operation.
// For this example, the userToken is a string constant.
string userState = stringFrom + "*&(k)&*" +
stringFromPass + "*&(k)&*" + stringTo + "*&(k)&*" +
stringBody + "*&(k)&*" + stringSubject + "*&(k)&*" + tryNb.ToString();
client.SendAsync(message, userState);
}
そして、必要なときにいつでもこの機能を呼び出しています。ovh サーバーの応答を受信しています:
sorry, invalid MAIL FROM for open-smtp session (http://travaux.ovh.com/?do=details&id=2602)
この最後のリンクで、彼らは次のように述べました。
messages sent via open-smtp will only be accepted if the email address of the fields From / Sender is the same connection login used for POP access.
私のコードでわかるように、私は POP を使用しておらず、その方法もわかりません。では、なぜこの制限があるのでしょうか? それを修正する方法は非常に高く評価されます。