I am using swift mailer to send emails and imap_append function to copy the the message in sent folder. The IMAP folder settings work properly with Yahoo and Hotmail accounts.
When mails are sent using a Gmail account SMTP and IMAP configuration, two copies are stored in the sender's "Sent" folder.
This is the IMAP code I am using:
$imapHostString = $mailSettings['imapServer'];
$imapHostString .= ($mailSettings['imapServerPort'] == 143)
? ":143"
: ":{$mailSettings['imapServerPort']}/imap/ssl/novalidate-cert";
$mbox = imap_open('{' . $imapHostString . '}INBOX', $mailSettings['username'], $password);
imap_append($mbox, '{' . $imapHostString . '}' . $mailSettings['sentDirectoryName'], $message->toString() . "\r\n");
imap_close($mbox);
Why this is happening? Are there any gmail settings to be done?