Take the 2-minute tour ×

When I'm sending a test message via PHPmailer (SMTP) my email appends to the recepients list. Here is what recipient sees in inbox email

To: mail@mail.com, Name <mail2@mail.com>

The second email is mine. How can I stop this?

Here is my code

function send_email($to, $fromName, $subject, $message, $contentType='text', $smtp_opts) {
    $mail = new PHPmailer();
    $mail->SetFrom($smtp_opts['fromEmail'], $fromName);
    $mail->Subject = $subject;
    $mail->Mailer = 'smtp';
    $mail->CharSet = "UTF-8";

    $mail->Host = $smtp_opts['host'];
    $mail->SMTPAuth = (bool)$smtp_opts['auth'];
    if ($mail->SMTPAuth) {
        $mail->Username = $smtp_opts['username'];
        $mail->Password = $smtp_opts['password'];

    $mail->Body = $message;
    $mail->AddAddress($smtp_opts['fromEmail'], $fromName);

    $result = $mail->Send();

    return $result;

$smtp_opts = array( ... ); // host, port, fromEmail, auth, username, password
send_email('mail@mail.com', 'Name', 'Subj', 'Msg', 'html', $smtp_opts);
share|improve this question

2 Answers 2

up vote 3 down vote accepted

If I am not mistaken, this command adds another recipient to the list of recipients. Try to remove it and send another test E-Mail. You shouldn't be getting the copy-mail then.

share|improve this answer
Oh my god!... I was sitting since morning looking for this mistake... Holy sh_t!:( –  Nikita Gavrilov Aug 4 '12 at 11:56
Thank you! I'm ashamed... –  Nikita Gavrilov Aug 4 '12 at 11:58
@NikitaGavrilov Don't sweat it, I know EXACTLY how you feel. Sometimes it just takes one glance from another person to spot the problem, the programmer has spent hours on looking for. Though it'd be nice if you accepted one of the answers :) Thank you. –  ATaylor Aug 4 '12 at 12:06

I think the problem is in this line $mail->AddAddress($smtp_opts['fromEmail'], $fromName);

share|improve this answer

Your Answer


