PHPMailer with locaweb - You are not saving the emails sent to my LocaWeb account

0

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?

    
asked by anonymous 27.08.2018 / 05:57

1 answer

0

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:

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

Example of sending copies

Sending as a copy:

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

Sending as a 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

Shipping mail with multiple senders and recipients

HTML email image in PHPMailer

Differences in PHPMailer functions

    
27.08.2018 / 12:08