tags:

views:

133

answers:

4

There is a weird error in a very basic implementation of phpmailer in which the subject line adds itself twice, its only been added once in the code:

$mailer->Subject = "My Subject";
$mailer->Send();

The output is that it gets the mail but with the Subject Line seen twice in the email client. Its very odd, and its not been set earlier on in the code.

Anyone seen this error and found a fix for it ?

A: 

Have you tried viewing the email in multiple clients? It seems that perhaps either your subject is being included in the header, or that your email client may well be showing it twice for some reason. Perhaps as a header for the email?

Personally I've never seen or heard of a bug of this nature.

DavidYell
A: 

PHPMailer's ->$Subject property is just a variable. Assigning a new value will not append it to the previous one, it'll overwrite and replace any previous subject. Unless you're using something like:

$mail->Subject .= 'extra subject bits';
or
$mail->Subject = $mail->Subject . 'extra subject bits';

then you'll have to look elsewhere to find the cause. Perhaps there's a bug in your mail server's configuration, or you've subclassed PHPMailer and your super-class is doing something funky.

You can check if it's the receiving server's problem by sending the same email to multiple accounts handled by different servers. ->AddBCC, ->AddCC, and ->AddAddress multiple times will take care of that. Just make sure the addresses are handled by different servers.

Marc B
A: 

I have the same problem, its just insane, I've tried anything I could think of. It might be some server setting! If anyone finds a solution, please post it. Thanks :)

Alex
+1  A: 

I solved the problem. There is a property called SingleTo, it needs to be set to true. http://phpmailer.worxware.com/index.php?pg=properties

$mail->SingleTo = true;

and it should work fine.

Alex