سؤال

وأنا أرسل البريد بسيط مع المرفق باستخدام SmtpClient لكن يمكنني الحصول على هذا الخطأ:

<اقتباس فقرة>   

صندوق البريد غير متوفرة. وكانت استجابة الملقم: المضيف لا المحلي   example.com، ليس من بوابة

     

وSystem.Net.Mail.SmtpFailedRecipientException:   صندوق البريد غير متوفرة.

     

واستجابة الملقم كانت في: example.com المضيف لا المحلي، وليس مدخلا في   System.Net.Mail.SmtpTransport.SendMail (MailAddress مرسل والمستفيدين MailAddressCollection، سلسلة deliveryNotify، SmtpFailedRecipientException واستثناء) في   System.Net.Mail.SmtpClient.Send (رسالة MailMessage)

ورمز:

public static void CreateMessageWithAttachment(byte[] compressed)
    {
        // Create a message and set up the recipients.
        MailMessage message = new MailMessage(
           "noreply@example.com",
           "recepient@example.com",
           "Hello.",
           "How are you?");

        // Create  the file attachment for this e-mail message.
        Stream attachStream = new MemoryStream(compressed);
        Attachment attachment = new Attachment(attachStream, MediaTypeNames.Application.Octet);
        message.Attachments.Add(attachment);

        //Send the message.
        SmtpClient client = new SmtpClient("123.12.12.123");
        // Add credentials if the SMTP server requires them.
        client.Credentials = CredentialCache.DefaultNetworkCredentials;

        client.Send(message);

        attachment.Dispose();
    }

وبالطبع المجال وIP غير صالح في التعليمات البرمجية الأصلية. لقد حاولت استخدام كل من "مضيف" وIP ولكن الحصول على نفس الخطأ. غوغلينغ عاد 3 النتائج التي واحدة مفيدة ويبدو أن في الصينية وجدار الحماية يمنعني من ترجمتها.

وشكرا مقدما.

هل كانت مفيدة؟

المحلول

ولقد بحثت عن: <لأ href = "http://www.google.co.in/search؟hl=en&safe=off&rlz=1C1GGLS_enIN292IN303&num=20&newwindow=1&q=C٪23+smtpclient+error+The+ الخادم + رد + كان: + لا + + المضيف المحلي + example.com، + لا + على + بوابة وbtnG = بحث وميتا = وعبد القدير = F & أوك = "يختلط =" نوفولو noreferrer "> C# smtpclient error The server response was: not local host example.com, not a gateway وحصلت 27K + النتائج

إذا كنت تستخدم المضيف المحلي إلقاء نظرة على هذه الصفحة تقول انها :

This is a relay error. Make sure you can relay through the SmtpMail.SmtpServer 
either by your IP address, by your MailMessage.From address, or if you need to 
authenticate, check out 3.8 How do I authenticate to send an email? 

If SmtpMail.SmtpServer is set to "127.0.0.1" or "localhost", and you are using 
the built in IIS SMTP Service, you can allow relaying for 127.0.0.1 by 

1) Opening the IIS Admin MMC
2) Right-Clicking on the SMTP Virtual Server and selecting Properties
3) On the Access tab, click the Relay button
4) Grant 127.0.0.1 (or the IP address used by System.Web.Mail) to the 
   Computers list.
5) Close all dialogs
6) Restarting the SMTP Service
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top