My postfix mail server is well setup and sending and receiving emails working fine, but any emails I send via SMTP gets sent properly, but I do not see them in the sent or outbox of the email account I send them with.
Logins and mails sent from gmail or Thunderbird app also work fine.
But SMTPs via PHP do not show in the outbox even though the mails are received correctly.
Hello @teners and welcome to the Virtualmin community.
From your message, it seems that your system is working normally. However, you expect that mail sent out by a PHP script will automatically show in the sent or outbox of the email account. This never happens, in Virtualmin or any other web hosting panel, because there is no connection between your stand-alone PHP script and the mail ecosystem (which uses of Postfix, Dovecot et al).
There exist CRM systems which enable you to use their equivalent of a form mail script that does what you want - the mail sent out from a CRM system will show in the sent / outbox folder. You should either use such a script / service or temper your expectations from a stand-alone PHP script.
Yes, you could certainly do that. You could write a script to do whatever you wish, of course. My point is that the SMTP protocol does not put mail in the sent / outbox folder.
I am convinced you should use a CRM software / service based on your recent comment that you wish to engage with people who have received mail from your PHP script - this falls perfectly within the scope of work of a CRM system.
The “sent” folder is not a thing SMTP servers like Postfix have anything to do with.
Your mail client puts email into a sent folder (if it supports doing so and if it’s configured to do so). If you expect a script that sends email to leave a message in a sent folder, you need to make it do so.
That’s a different question. Postfix has nothing to do with a “sent” folder. If you want to talk about how to send email, make a new topic. If you want to talk about sent folders and how they work, we can keep talking here. The two are not related. Your mail client communicates with Dovecot via IMAP or POP3 to put sent messages into a “sent” folder, and communicates with Postfix to send email via SMTP. Your script running on the server itself has more options for putting mail into a sent folder. It could do it the same way as Thunderbird, and talk to Dovecot via IMAP or POP, but it’d be easier to drop it directly into the right directory, or just log that an email was sent.