首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从c#发送电子邮件时出现ARC-Authentication-Results错误

问从c#发送电子邮件时出现ARC-Authentication-Results错误
EN

Stack Overflow用户
提问于 2019-02-07 08:32:16
回答 1查看 82关注 0票数 0

我试着把工资单发给我们所有的员工,但是有一堆gmail账户的邮件被延迟或屏蔽了。

我已经使用GSuite帐户进行了测试,并收到了电子邮件,但在电子邮件的“原始电子邮件”视图中,我看到以下行:

代码语言:javascript
复制
 ARC-Authentication-Results: i=1; mx.google.com;
 spf=permerror (google.com: permanent error in processing during lookup
 of no-reply@our-domain.com.au: mail.optusnet.com.au not found)
 smtp.mailfrom=no-reply@our-domain.com.au

和

代码语言:javascript
复制
 Received-SPF: permerror (google.com: permanent error in processing during
 lookup of no-reply@our-domain.com.au: mail.optusnet.com.au not found)
 client-ip=000.000.00.000;

我们有一个有效的SPF记录,允许通过O365从我们的服务器发送电子邮件。

这是我用来发送电子邮件的类。我正在使用一个Parallel.ForEach循环来发送电子邮件。在生产中最大线程数为3或4。

代码语言:javascript
复制
public class EmailService : IDisposable
{
    public const string DefaultFromAddress = "no-reply@our-domain.com.au";
    private const string Office365Host = "smtp.office365.com";
    private const int Office365Port = 587;
    private const string Office365UserName = "O365_App_UserName";
    private const string Office365Password = @"--Password--";

    //private readonly SmtpClient _smtpClient;
    private SmtpClient _smtpClient;
    private readonly Logger _logger;

    public EmailService()
    {
        _logger = LogManager.GetCurrentClassLogger();
        _smtpClient = new SmtpClient
        {
            Host = Office365Host,
            Port = Office365Port,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential(Office365UserName, Office365Password),
            DeliveryMethod = SmtpDeliveryMethod.Network,
            EnableSsl = true,
            TargetName = "STARTTLS/smtp.office365.com"
        };
    }

    public bool SendEmail(MailMessage message)
    {
        try
        {
            _smtpClient.Send(message);
        }
        catch (Exception ex)
        {
            _logger.Error(ex, $"Failed to send email: from: {message.From.Address}, to:{message.To.First()}. more details:{ex.InnerException}");
            return false;
        }
        return true;
    }

    public void Dispose()
    {
        _smtpClient.Dispose();
    }
}

以下是发送编写的消息的循环中的代码:

代码语言:javascript
复制
using (EmailService emailService = new EmailService())
{
  employee.EmailSent = emailService.SendEmail(mailMessage);
}

这里我漏掉了什么?我们也需要对mail.optusnet.com.au的SPF记录做些什么吗?

任何其他的建议都将不胜感激。谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-02-13 11:39:33

我找到了我的问题的解决方案。经过挖掘和测试,我的代码没有任何问题,这与DNS记录有关。SPF类型记录已被TXT类型记录取代。谷歌似乎更安全,正在检查SPF类型,在该条目中列出的每个域上都失败了。当我将它们从记录中删除时,一个新的域名出现了。然后,我们完全删除了SPF类型,错误也消失了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54564683

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档