SMTP Realy Issue

I just started using mail-in-a-box and was surprised at how good it is. I was up and running in minutes. I managed to connect to it with thunderbird and emails all working perfectly. I have an email account on there with forum@mydomain.co.uk.

I want to use it as my SMTP server for my websites, but have been having issues with emails being rejected. I typically got error messages in my /var/log/mail.log file like:

Oct 13 12:07:57 ip-172-31-12-116 postfix/smtp[6830]: ED13560347: to=<someEmail@gmail.com>, relay=mail-in-a-box.mydomain.co.uk[178.xx.xx.38]:587, delay=0.15, delays=0.01/0.01/0.1/0.02, dsn=5.7.1, status=bounced (host mail-in-a-box.mydomain.co.uk[178.xx.xx.38] said: 553 5.7.1 <www-data@mydomain.co.uk>: Sender address rejected: not owned by user forum@mydomain.co.uk (in reply to RCPT TO command))

It looks like sendmail would always send using the local user that was sending the email, rather than the one that was programmed in. For example, the forum is running as the www-data user so the emails were from www-data@mydomain.co.uk instead of the one set in the forum (forum@mydomain.co.uk). Likewise, if I manually tried to run the sendmail command, it would appear in the error logs as coming from the admin user I had SSHd into the server with.

I had to get around this by editing the apache php.ini file and changing the sendmail_path parameter from:

sendmail_path = /usr/sbin/sendmail -t -i
```
...to
```
sendmail_path = /usr/sbin/sendmail -t -i -f "forum@mydomain.co.uk"
```

I swear I have had this work with other SMTP providers where the "from" mail is used in the sendmail usage by the PHP website and that is what is sent from, rather than the www-data user (hopefully that makes sense). For now this works, but I would like to be able to rely on the "from" input field in my website, and not have to remember than I hardcoded it into the php.ini file. Is there some workaround to this other than possibly setting up a www-data@mydomain.co.uk?

Apologies, but I would correct the formatting, but I get the following error message for some reason:

Selection_075

Your best plan of attack would be to use a SMTP configuration in your forum software if that software supports it - most do.
Next option, I would set postfix on the remote server to relay via your MiaB. In this case you should be able to send as any user that has an account on MiaB.

As a new user to the forum your post count and link count are limited - the limits will be lifted after either 24 or 48 hours.

Try this: https://www.bonusbits.com/wiki/HowTo:Configure_SendMail_to_Use_SMTP_Relay

Use your MIAB server as the relay server and BOOM anything using sendmail will send as the configured user (I recommend a noreply@example.com account specific for your server - any other addresses you want to send as need to be setup as an alias for the account used in order to be authenticated by MIAB)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.