Hello!
Has anything changed regarding the topic below?
How can I properly configure SMTP so that each domain has its own SMTP server separately? Also, how can I ensure PHP scripts can use the sendmail function without requiring additional plugins, etc.?
I have no idea what you’re asking. That link leads to a huge confused conversation.
Anything can use the sendmail command in a Virtualmin system. The PHP mail() function can send mail via the local mail server using the sendmail command. There is no standard PHP sendmail() function that I am aware of, so I don’t know what you’re doing.
I am not a PHP developer, but I believe mail() defaults to sending via localhost:25, which will work fine (with no authentication required), unless you have altered your configuration. If you have altered your configuration to require auth on localhost, you’ll obviously need to configure your mail client to authenticate.
This is unrelated to what I’m guessing your other questions are, I think. So, it should be a separate topic. Unless you’re asking about PHP. In which case, every domain will have its own php.ini and will be running their own PHP applications, and so you can configure them in any way you want, including using the local SMTP server or a remote one. (Or are you asking about running multiple Postfix instances? That’s almost certainly a bad idea, but clarify that in your new topic about this question.)
If you’re sending through localhost:25 your mail is going through Postfix, and will get whatever treatment mail via Postfix gets (DKIM, if enabled, for example). As far as I recall, you can make mail() send through the local SMTP server, and in fact, I thought that was the default. I’m certain there’s no PHP library that is better at sending mail than Postfix. (There are certainly many other features one might want when sending mail, but there’s no reason mail() needs to be less reliable than mail in general on your system. Though deliverability can be a challenge, regardless of what software is involved in sending mail…if you’re on an IP that has sent spam in the past, it’ll take some work to get it unblocked broadly.)
Modern PHP development should generally NOT use the “mail” function in PHP, as it sends directly through the “sendmail” script on the system, therefore it DOES NOT sign mail with DKIM or otherwise adhere to DMARC protocol.
When developing PHP code, it’s recommended to use a library such as “PHPMailer” which does a proper SMTP connection and therefore sends mail out with all the appropriate headers and therefore will not be blocked by receiving servers due to missing headers and such.
Are you sure about that? How is sending with the Postfix mail injection command (sendmail command on a system using Postfix as its MTA is the Postfix mail injection command) not getting DKIM? I just can’t figure out what path mail would take that would be different. sendmail just puts mail in the Postfix outgoing queue. If mail() doesn’t get the usual mail treatment, I can’t figure out how.
Edit: I’m not saying anybody should use mail(), I have no idea. I just want to understand how it’s sending mail, if it isn’t getting DKIM.