I configured PHPMailer and it is correctly sending the emails, however in the sent box of my locaWeb account these sent emails do not register. Do I have to do some configuration for this?
I configured PHPMailer and it is correctly sending the emails, however in the sent box of my locaWeb account these sent emails do not register. Do I have to do some configuration for this?
There is no way to be saved, as is the role of the email manager you are using.
With PHPMailer , you are not using any, just authenticating to send the email, so there is no copy left.
Some options:
Sending as a copy:
$mail->addCC('[email protected]');
Sending as a hidden copy:
$mail->addBCC('[email protected]');
# verificação se o e-mail foi enviado ou teve erros
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
$save_result = save_mail($mail); # chama a função para envio da cópia via IMAP
if ($save_result) {
echo "Message saved!";
}
}
# função para chamar IMAP: https://php.net/manual/en/book.imap.php
function save_mail($mail) {
# Você pode enviar para a pasta de enviados ou alguma tag
$path = "{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail";
# autenticando
$imapStream = imap_open($path, $mail->Username, $mail->Password);
# você pode usar imap_getmailboxes($imapStream, '/imap/ssl') para obter a lista de pastas e tags
//Can be useful if you are trying to get this working on a non-Gmail IMAP server.
$result = imap_append($imapStream, $path, $mail->getSentMIMEMessage());
imap_close($imapStream);
# retorna o resultado
return $result;
}
Some links about PHPMailer: