In general, there is a server on Debian, there is PHP and sendmail, sending mail from PHP through sendmail is somehow configured. Letters from the server are sent as root@domain.com by default, unless you specify the From header in mail (). If you specify an additional From header, for example, info@domain.com, then the letters come from either root@domain.com or from info @, but with a completely left domain after @ (and naturally falls into spam).

You do not need to receive mail on the server; you only need to send it normally. Actually 2 questions in the end:

  1. How can I change the user (box) by default (so that letters are sent not from root@domain.com, but from a mailbox more decently on the same domain)?

  2. How to set up sending letters from any mailbox on this domain (*@domain.com), that is, so that they come from the corresponding mailbox (info@domain.com, admin@domain.com)?

  • put www-data into trusted users, if you really have sendmail there - zb '

1 answer 1

First you need to read how to call the mail() function in PHP.
Then we make the following call:

 mail('someuser@example.net', $subj, $mailbody, $additional_headers, '-f from@domain.com'); 

The -f option is very important here. it is he who sets the user from which the mail will go.