简体   繁体   English

邮件已发送但未收到

[英]Mail has been Sent But does not received

I am struggling almost a week for this issue. 我为此问题奋斗了几乎一个星期。 this is my code 这是我的代码

public string GenerateEmail(EmailConfigDetail emailConfig)
    {
        MailMessage mailMessage = new MailMessage();
        try
        {
            if (emailConfig != null)
            {
                fromMailId = emailConfig.fromMailId;
                toMailId = emailConfig.toMailId;
                hostAddress = emailConfig.hostAddress;
                Body = emailConfig.Body;
                subject = emailConfig.subject;
                attachmentPath = emailConfig.AttachmentFilePath;
            }


            mailMessage.To.Add(toMailId);
            mailMessage.From = new MailAddress(fromMailId);
            mailMessage.Subject = subject;
            mailMessage.Body = Body;
            mailMessage.IsBodyHtml = true;
            if (!string.IsNullOrWhiteSpace(attachmentPath))
            {
                Attachment attachment = new Attachment(attachmentPath, MediaTypeNames.Application.Pdf);
                //ContentDisposition disposition = attachment.ContentDisposition;
                string guid = attachment.Name.Split('_')[2];
                attachment.Name = attachment.Name.Replace('_' + guid, string.Empty);
                mailMessage.Attachments.Add(attachment);
            }

            SmtpClient smtp = new SmtpClient();
            smtp.Host = hostAddress;
            smtp.Credentials = new System.Net.NetworkCredential();
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl = true;
            ServicePointManager.ServerCertificateValidationCallback =
              delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
              { return true; };

            smtp.Send(mailMessage);
            DisposeMailAttachments(mailMessage);
            retVal = "Email sent successfully";
            return retVal;
        }
        catch (Exception ex)
        {
            DisposeMailAttachments(mailMessage);
            throw ex;
        }
        finally
        {
            DisposeMailAttachments(mailMessage);
        }

    }

My above code is working fine while am sending mail. 我上面的代码在发送邮件时工作正常。 And I got a exact message "Email sent successfully"; 而且我收到了准确的消息"Email sent successfully"; without any error. 没有任何错误。 but I am not able to receive any mail in my to address. 但我无法在我的收件地址中收到任何邮件。 I have asked my admin team and support team. 我已经问过我的管理团队和支持团队。 they are telling no issues in their side. 他们没有告诉他们任何问题。 Could you please suggest me if i am missing anything. 如果我想念什么,请您建议我。

From address: no-reply@mydomain.com
To Address: ramesh.rajendran@mydomain.com

如果我禁用了SSL,它就可以正常工作

smtp.EnableSsl = false;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM