Phpmailer with Locaweb - Not saving emails sent in my Locaweb account

Asked

Viewed 424 times

0

I have set up Phpmailer and it is sending the emails correctly, but in the mailbox of my account these sent emails are not registered. I have to make some configuration for that?

1 answer

1


There’s no way they can be saved, because this is function of mail manager whatever you’re using.

With the Phpmailer, is not using any, only authenticating to send the email, so there is the copy.

Some options:

  • Send a copy to you, and make a filter in your manager, which identifies that the email was sent by you, and then save it in the sent folder.
  • Utilise IMAP

Example of sending copies

Sending as copy:

$mail->addCC('[email protected]');

Sending as hidden copy:

$mail->addBCC('[email protected]');

IMAP (example with GMAIL)

# 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;
}

Example via IMAP


More

Some links about Phpmailer:

Phpmailer

Sending email with multiple senders and recipients

Image in HTML e-mail in Phpmailer

Differences in Phpmailer functions

  • Wow, thank you so much!! It will help so much.

  • @Trimander any doubt we’re there!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.