Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SMTPFailedRecipient我测试的所有电子邮件地址的异常_C#_Email_Smtp_Smtpclient - Fatal编程技术网

C# SMTPFailedRecipient我测试的所有电子邮件地址的异常

C# SMTPFailedRecipient我测试的所有电子邮件地址的异常,c#,email,smtp,smtpclient,C#,Email,Smtp,Smtpclient,我正在使用此代码发送电子邮件: MailMessage mail = new MailMessage(); SmtpClient smtp = new SmtpClient(_smtpServer, _smtpPort); smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(_smtpUser, _smtpPa

我正在使用此代码发送电子邮件:

        MailMessage mail = new MailMessage();
        SmtpClient smtp = new SmtpClient(_smtpServer, _smtpPort);
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new System.Net.NetworkCredential(_smtpUser, _smtpPassword);
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtp.EnableSsl = _smtpSSL;
        mail.From = new MailAddress(_fromEmail);
        mail.To.Add(new MailAddress(toEmail, toName));
        if (!String.IsNullOrEmpty(ccEmail))
            mail.CC.Add(new MailAddress(ccEmail, ccName));
        mail.Subject = subject;
        mail.Body = body;
        mail.Priority = MailPriority.High;
        if (attachment != null)
        {
            if (String.IsNullOrEmpty(fileName))
                fileName = "Adjunto " + DateTime.Today.ToString("yyyyMMddHHmmss" + ".pdf");
            mail.Attachments.Add(new Attachment(attachment, fileName, "application/pdf"));
        }
        smtp.Send(mail);

        return true;
问题是收件人只有一个,而且邮箱确实存在。但是,调用smtp.Send方法时,会引发以下异常:

{"No se pueden enviar todos los destinatarios."}
    [System.Net.Mail.SmtpFailedRecipientsException]: {"No se pueden enviar todos los destinatarios."}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    HResult: -2146233088
    InnerException: {"El buzón de correo no está disponible. La respuesta del servidor fue: User unknown / Usuario desconocido / Usuario desconhecido"}
    Message: "No se pueden enviar todos los destinatarios."
    Source: "System"
    StackTrace: "   en System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)\r\n   en System.Net.Mail.SmtpClient.Send(MailMessage message)\r\n   en Common.MailHelper.Send(String toEmail, String toName, String ccEmail, String ccName, String subject, String body, MemoryStream attachment, String fileName) en c:\\WorkingFolder\\Proyectos\\Evcom\\Asistencia\\Nueva Normativa\\Asistencia\\Common\\MailHelper.cs:línea 55\r\n   en Common.Ticket.Send(MailHelper mailHelper, MemoryStream pdfStream, String toEmail, String ccEmail) en c:\\WorkingFolder\\Proyectos\\Evcom\\Asistencia\\Nueva Normativa\\Asistencia\\Common\\Ticket.cs:línea 203"
    TargetSite: {System.Net.Mail.MailWriter SendMail(System.Net.Mail.MailAddress, System.Net.Mail.MailAddressCollection, System.String, Boolean, System.Net.Mail.SmtpFailedRecipientException ByRef)}

你能帮我吗?

听起来你想通过smtp服务器转发电子邮件,但该服务器不允许你这么做

如果您要发送到SMTP服务器希望代表其接收邮件的地址(如果您对要发送到的域的MX记录执行nslookup,则会显示该地址),则该地址通常会正常工作。但是,如果邮箱不存在,某些邮件服务器将不接受邮件。我相信这就是你的服务器在这种情况下告诉你的。其他人会接受它,并在没有错误的情况下丢弃它,因此,如果你是垃圾邮件发送者,你不能使用错误来确定虚构的电子邮件地址是否有效


如果您发送到的SMTP服务器不是它期望的地址,则您要求它中继电子邮件。大多数服务器通常不允许这样做,除非您经过身份验证并拥有相应的权限。

该服务器是我的,我使用compact framework应用程序通过它发送电子邮件。在这种情况下,我使用其他smtp服务器帐户发送电子邮件。我将尝试使用与其他应用程序相同的SMTP参数。