Я обновил наш почтовый сервер использовать DMARC. Поэтому после этого наша ERP-система не может отправлять электронные письма на gmail.com или yahoo.com, но Outlook отправляет электронные письма без проблем.
Ниже приведен заголовок электронного письма, которое было отправлено из моего домена в Gmail и доставлено благополучно:
Message ID <4bcfe9f3-0eb7-98cf-dcaf-0440d4a5e67f@domain.com>
Created at: Fri, Jul 16, 2021 at 11:30 AM (Delivered after 4 seconds)
From: me
To: me@gmail.com
Subject: Check1
SPF: PASS with IP 000.000.000.000 (mail server IP) Learn more
DKIM: 'PASS' with domain domain.com Learn more
DMARC: 'PASS' Learn more
но когда мы используем приведенный ниже код для отправки из нашей ERP:
defined('BASEPATH') OR exit('No direct script access allowed');
class SendPO extends CI_Controller {
var $role,$user,$brand;
public function __construct()
{
parent::__construct();
$this->load->helper('url');
}
public function index(){
$mailTo = "me@gmail.com";
$subject = "Mail check ";
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'mail.example.com',
'smtp_port' => 465,
'smtp_user' => 'erp.email@example.com',
'smtp_pass' => 'some-password',
'charset'=>'utf-8',
'validate'=>TRUE,
'wordwrap'=> TRUE,
'dkim_domain' => 'example.com',
'dkim_private' => '/home/ubuntu/mail.private',
'dkim_selector' => 'mail',
'dkim_passphrase' => '',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from("me@example.com");
$this->email->cc("me@example.com");
// replace my mail by user it is just for testing
$this->email->to($mailTo);
$this->email->subject($subject);
$msg="Mail check";
//echo $msg;
$this->email->message($msg);
$this->email->set_header('Reply-To', $userMail);
$this->email->set_mailtype('html');
$this->email->send();
}
}
?>
Я вижу это письмо «Возвращенное письмо: см. расшифровка подробностей »
The original message was received on Fri, 16 Jul 2021 11:22:05 +0200
с erp.domain.com [127.0.0.1]
----- The following addresses had permanent fatal errors -----
(reason: 550-5.7.26 Unauthenticated email from example.com is not accepted due)
----- Transcript of session follows -----
... while talking to gmail-smtp-in.l.google.com.:
>>> DATA
<<< 550-5.7.26 Unauthenticated email from example.com is not accepted due
<<< 550-5.7.26 to domain's DMARC policy. Please contact the administrator of
<<< 550-5.7.26 example.com domain if this was a legitimate mail.
Please
<<< 550-5.7.26 visit
<<< 550-5.7.26 https://support.google.com/mail/answer/2451690 to learn about the
<<< 550 5.7.26 DMARC initiative. g11si7705633pfc.152 - gsmtp
554 5.0.0 Служба недоступна
Reporting-MTA: dns; erp.domain.com
Received-From-MTA: DNS; erp.domain.com
Arrival-Date: Fri, 16 Jul 2021 11:22:05 +0200
Final-Recipient: RFC822; me@gmail.com
Action: failed
Status: 5.7.26
Remote-MTA: DNS; gmail-smtp-in.l.google.com
Diagnostic-Code: SMTP; 550-5.7.26 Unauthenticated email from example.com is not accepted due
Last-Attempt-Date: Fri, 16 Jul 2021 11:22:05 +0200
Return-Path:
Received: from erp.example.com (erp.example.com [127.0.0.1])
by erp.example.com (8.15.2/8.15.2/Debian-3) with ESMTP id 16G9M5eY021733;
Fri, 16 Jul 2021 11:22:05 +0200
Received: (from www-data@localhost)
by erp.domain.com (8.15.2/8.15.2/Submit) id 16G9M5NP021732;
Fri, 16 Jul 2021 11:22:05 +0200
X-Authentication-Warning: erp.domain.com: www-data set sender to me@example.com using -f
To: me@gmail.com
Subject: =?UTF-8?Q?Vendor=20VPO=20Test=20?=
X-PHP-Originating-Script: 0:Email.php
User-Agent: CodeIgniter
Date: Fri, 16 Jul 2021 11:22:05 +0200
From:
Cc: me@example.com
Reply-To:
X-Sender: me@domain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <60f14fbd23c93@example.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_60f14fbd23d53"
Я провел тесты на https://www.mail-tester.com/ и показывает 10/10
Когда я провожу тест на https://toolbox.googleapps.com/ , он показывает:
error
DKIM authentication DNS setup.
DKIM technology is used to help detection of unauthorized mail that pretends to be sent out from your domain.
Invalid format of DKIM record.
v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjYVyZyyl6T...
error
SPF must allow Google servers to send mail on behalf of your domain.
Decision SPF fail - not authorized
Record v=spf1 mx a ip4:000.000.000.000 -all
warning
No Google mail exchangers were found. Relay host configuration?
If you intentionally set up a mail server somewhere on your premises that automatically forwards all incoming mail to Google you may disregard this warning. Otherwise - this is a serious configuration error as it causes disruption of mail flow.
0 mail.example.com
info_outline
Effective SPF Address Ranges.
The following IP addresses are taken from the includes and IP4/IP6 directives within this domain's SPF record.
example.com.
000.000.000.000
Я думаю, причина в части этой страницы (Подпись родительскими доменами):
https://datatracker.ietf.org/doc/html/rfc6376#section-3.10
Если мое мнение верно! Может ли кто-нибудь предоставить правильный формат для записи SPF?
Если я ошибаюсь! Я надеюсь, что какая-то помощь поможет разобраться в том, что происходит
Мне удалось исправить это с помощью других... Спасибо всем вам, дорогие. Заметка: IP сервера почты 000.000.000.000 IP ERP сервера 111.111.111.111.111 Указана причина проблемы: 550-5.7.26 Неаутентиченная электронная почта от example.com не принимается из-за политики DMARC домена Но DKIM и DMARC не являются целями для исправления.
Основная причина проблемы: ERP не работает, так как домен me@example.com обозначает 111.111.111.111 (IP-адрес ERP) не разрешен, отправитель) smtp.mailfrom=me@example.com
Как это решено: 1- Обновлен код в файле ERP "send-email.php"
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'mail.example.com',
'smtp_port' => 465,
'smtp_user' => 'system-mail@example.com',
'smtp_pass' => 'password',
'charset'=>'utf-8',
'validate'=>TRUE,
'wordwrap'=> TRUE,
'dkim_domain' => 'example.com',
'dkim_selector' => 'mail',
2- Демон почтовой службы на ERP-сервере оснащен возможностями ретрансляционной отправки, как показано в приведенном ниже руководстве. https://www.bonusbits.com/wiki/HowTo:Configure_SendMail_to_Use_SMTP_Relay
4- Обновлены записи DNS в Cpanel хостинговой компании, чтобы они соответствовали внесенным изменениям.
Запись хоста: @ Значение TXT: v=spf1 mx a ip4:000.000.000.000 ip4:111.111.111.111 ~все
И обновлено: Запись хоста: почта Значение TXT: v=spf1 mx a ip4:000.000.000.000 ip4:111.111.111.111 -all
Еще раз хочу поблагодарить всех вас за любую информацию и усилия, которые вы предприняли в последние дни :)