Since I separated my mailserver from the apache/webserver for the same domain, I worry about mails which are sent e.g. via php from the webserver to @same-domain.com. It's trying to deliver the message on localhost although the email server (target) is another machine :-(
How to fix the route to get the mails delivered?
Thanks
You just need to make sure that Sendmail on the web server does not think same-domain.com is a local name, which should be as simple as removing it from the local-host-names file (I'd also remove any references from the virtusertable if it's in there).
If the web & mail server are on the same network I would also suggest configuring your web server to use your mail server as a smart host so that the web server forwards all mail to it and let the mail server handle all mail delivery. This is done with the DS option in sendmail.cf but depending on your OS this file may be auto-generated from an mc file. On my systems I have a {hostname}.mc file in /etc/mail that contains a SMART_HOST option. This can then be used to generate a new sendmail.cf by running make in the same directory.