PHP Mail с ошибкой с сообщением «530,5.7.0SMTP server error: MAIL FROM command failed Detail: Authentication Required»
Ниже приведены ключевые разделы моего сценария PHP. новый PHPMailer (правда) Хост как "smtp.gmail.com" SetFrom ( 'MyUsername-Of-Ubuntu-Login@mail.theDomainCreatedInPostfixCOnfigu ration.com') Port = 587 SMTPSecure = 'tls' Имя пользователя = "один из моего-gmail-email-id" Пароль = "пароль-учетной записи Gmail" SMTPOptions = массив ( 'ssl' => массив ( 'cafile' => '/etc/postfix/cacert.pem', 'verify_peer' => ложь, 'verify_peer_name' => ложь, 'allow_self_signed' => истина )
В рамках устранения неполадок я сделал следующее:
sudo apt-get install libsasl2-modules
В / etc / postfix / sasl_passwd добавьте эти вещи [Smtp.gmail.com]: 587 gmailusername: gmailapppassword
sudo postmap /etc/postfix/sasl_passwd sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Add below lines at end of main.cf
# enable SASL authentication
smtp_sasl_auth_enable = yes # запретить методы, разрешающие анонимную аутентификацию. smtp_sasl_security_options = noanonymous # где найти sasl_passwd smtp_sasl_password_maps = хеш: / etc / postfix / sasl_passwd # Включить шифрование STARTTLS smtp_use_tls = yes # где найти сертификаты CA smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
sudo service postfix restart
Hope your issue will resolve