5

I'm trying to use Zoho's SMTP servers to send registration emails from a MyBB installation. However, the emails are never sent and when I check the logs I notice that the error is.

Month Day Year:Hour:Minute host=smtp.zoho.com tls=on auth=on user=user[at]mydomain.com from=user[at]mydomain.com recipients=some.user[at]gmail.com smtpstatus=553 smtpmsg='553 Relaying disallowed' errormsg='the server did not accept the mail' exitcode=EX_UNAVAILABLE

(Some parts were masked to hide private information!)

This is the sendmail path set in php.ini

sendmail_path = "/usr/bin/msmtp -C /etc/msmtp/myserver --logfile /var/log/msmtp/myserver.log -a default -t"

(Some parts were masked to hide private information!)

This is the myserver configuration for MSMTP

# Define here some setting that can be useful for every account
defaults
    logfile /var/log/msmtp/general.log

# Settings for default account
account default
    protocol smtp
    host smtp.zoho.com
    tls on
    tls_starttls off
    tls_certcheck off
    port 465
    auth plain
    user user[at]mydomain.com
    password **********
    from user[at]mydomain.com
    logfile /var/log/msmtp/myserver.log

# If you don't use any "-a" parameter in your command line,
# the default account "default" will be used.
# account default: default # (disabled because this gives a "redefined" error)

(Some parts were masked to hide private information!)

The problem is that I know it's working and that no ports are blocked because when I use the same command in the command line. The email is successfully sent and received.

sudo echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" | msmtp --debug -a default --from=user[at]mydomain.com -t some.user[at]gmail.com --file=/etc/msmtp/myserver

(Some parts were masked to hide private information!)

Which means that it's either something wrong with the way MyBB sends emails or it's something wrong with my PHP configuration or command line that I have set in php.ini file.

I've searched this all day but every result that I get is either not related to PHP or it never worked from the beginning. And mine is working from the command line but not from PHP.

I use UFW on the server and every port is completely opened so I'me guessing it's not related to blocked ports.

It worked with Gmail but every email was sent to spam folder and it didn't worked every time with every email.

EDIT: I've tried to send an email with PHP5-CLI and it worked. So I'm guessing that it's either something wrong with PHP5-FPM or MyBB.

SLC
  • 2,167
  • 2
  • 28
  • 46

1 Answers1

0

I can't test this without a MyBB install, but if it uses the native PHP mail function, you may need to add the -f option to the mail() function call since you are using sendmail.. Note it is the 5th parameter (I wasted a day once thinking it the was 4th)

mail('nobody@example.com', 'the subject', 'the message', null,
'-flocaluserr@thisdomain.com'); 
Duane Lortie
  • 1,285
  • 1
  • 12
  • 16