PHPMailer, e-mails not saved in 'sent' directory

Can You tell me please how to send e-mails correctly using PHP and Postfix? I have default Virtualmin GPL install.

$mail = new PHPMailer();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = “localhost”; // sets the SMTP server
$mail->Port = 25; // set the SMTP port
$mail->Username = “ads”; // username
$mail->Password = “mypassword”; // password

I can send e-mail in this way but sent items are not saved in "sent" folder (I can not see it in https://localhost:20000 in "sent" folder).

Thank You for answers!

Sending emails via Postfix won’t cause email to be saved in the “Sent” folder… programs like Usermin and Outlook and such all have code built into them which connects to the IMAP server, and explicitly submit a copy of the message to the Sent folder.

So, it’s not a function of Postfix, the MTA, it’s a function of the mail client.

For the case of your example, you would need to add additional PHP code to your script to save the message to the Sent folder via IMAP – here’s the PHP IMAP functions:

Thank You! The PHP function I was searching for was ‘imap_append’!
I thought postfix saves sent e-mails now I know that this is done by imap server :slight_smile: