PHP Mail error with the message:
530,5.7.0SMTP server error: MAIL FROM command failed Detail: Authentication Required
Following are the key sections of my PHP Script.
new PHPMailer(true)
Host as 'smtp.gmail.com'
SetFrom('MyUsername-Of-Ubuntu-Login@mail.theDomainCreatedInPostfixCOnfiguration.com')
Port=587
SMTPSecure = 'tls'
Username = "one-of-my-gmail-email-id"
Password = "gmail-account-password"
SMTPOptions = array(
'ssl' => array(
'cafile' => '/etc/postfix/cacert.pem',
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
As part of my troubleshooting, I did following:
In
/etc/mail/sendmail.inc, un-commented the following by removing the prefix"dnl #use/etc/mail/local-host-namesAnd, I do have list of my host-names in the
/etc/mail/local-host-namesexecuted the command :
$ make -C /etc/mail
Edited
/etc/postfix/main.cfwith following values:mydomain = theDomainCreatedInPostfixCOnfiguration.com relay_domains = theDomainCreatedInPostfixCOnfiguration.com smtpd_sasl_security_options = noanonymous,noplaintext mynetworks = 127.0.0.0/8 TheIPaddressOfMyUbuntuMachineWifi relayhost = smtp.gmail.com myorigin = /etc/mailname myhostname = mail.theDomainCreatedInPostfixCOnfiguration.com smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdIn
/etc/mailname, I havemail.theDomainCreatedInPostfixCOnfiguration.comIn
/etc/aliases, I haveroot: MyUsername-Of-Ubuntu-Login daemon: MyUsername-Of-Ubuntu-Login postmaster: MyUsername-Of-Ubuntu-LoginI ran command:
systemctl reload postfixI ran command:
sudo postmap /etc/aliases, and builtaliases.db