Author Topic: How to Save a Copy of Sent Emails into Sent Folder in cPanel and Dovecot  (Read 507 times)

Offline mohsenheshmati

  • Newbie
  • *
  • Posts: 1
I'm using cPanel SMTP with Dovecot email service.

I Wana Send emails from WinForms Software and it's ok, but sent emails aren't in 'Sent Folder'. Even I added Custom Header but isn't successful.

How can I Fix that?

Code: [Select]
   var message = new MimeMessage();
        message.From.Add(new MailboxAddress("Mohsen", "email@domain.com"));
        message.To.Add(new MailboxAddress("DEw ", "receiving@domain.com"));

        message.Subject = "SentFolder";
        var builder = new BodyBuilder();
        builder.HtmlBody = "Dear Colleague,<br /> ";
        message.Body = builder.ToMessageBody();
        message.Headers.Add((HeaderId) 1, "X-Save-Sent: 1");
        using (var client = new SmtpClient())
        {
            client.Connect("mail.domain.com", 587, false);
            client.Authenticate("UserName", "Password");
            client.Send(message);
            client.Disconnect(true);}

here is dovecot link to fix this :

https://dovecot.org/list/dovecot/2008-May/030657.html
Quote
1- dovecot LDA and use Sieve to store the message in the folder you want
2- maildrop and configure it to store the message where you like, or
 3- directly with postfix, provided you configure the right virtual_mailbox_maps or.. just add custom header line like "X-Save-Sent: 1" and use dovecot's LDA + sieve script to store a message in "sent" folder. Personally, I don't like fake "senderbcc" address for every user. This may catch a lot of spam in "sent" folders.
My Question is How RoundCube fixed That .there is a CheckBox to save a copy of sent emails in Sent Folder in RoundCube Compose Form. how can I do it in C#? what method RoundCube used for it

Best Regards

Offline rm13

  • Full Member
  • ***
  • Posts: 129
Re: How to Save a Copy of Sent Emails into Sent Folder in cPanel and Dovecot
« Reply #1 on: December 27, 2018, 04:02:59 PM »
I don't see how this pertains to using Roundcube. Anyhow, the gist is to have your code save a copy to the Sent folder after it is sent.

Not sure how helpful looking at the PHP code is but I believe the save_message function is where this happens in Roundcube.

https://github.com/roundcube/roundcubemail/blob/master/program/lib/Roundcube/rcube_imap.php#L2558

Sounds like you want a C# IMAP library.