php - PHPMailer: Insert a signature block in an HTML email


I've been using PHPMailer without too many issues, but the last request I received had me spending hours without a solution. No one else seems to have had that issue and not a single example can be found online.

We generate the HTML email in real time because it has to be populated by some calculated field, so no import from a file. I've been asked to insert an ordinary signature with the usual standard prefix "-- ". The problem is: no matter what I try, no email client recognizes the signature block.

I'm aware that it usually is just an ordinary dash dash space \n. No rocket science here. Yet...

Some solution I tried, sparsed:

    $body .= "-- ";
    $body .= "-- <br>";
    $body .= "-- " . PHP_EOL;
    $body .= "<p>-- </p>";
    $body .= "-- \n";
    $body .= "-- \n<br>";
    $body .= "-- \n" . PHP_EOL;
    $body .= "<p>-- \n</p>";
    $body .= "--&nbsp;\n";
    $body .= "--&nbsp;\n<br>";
    $body .= "--&nbsp;\n" . PHP_EOL;
    $body .= "<p>--&nbsp;\n</p>";
    $body .= "--  \n";
    $body .= "--  \n<br>";
    $body .= "--  \n" . PHP_EOL;
    $body .= "<p>-- \n</p>";
    $body .= "-- \r\n";
    $body .= "-- \r\n<br>";
    $body .= "-- \r\n" . PHP_EOL;
    $body .= "<p>-- \r\n</p>";
    $body .= "--  \r\n";
    $body .= "--  \r\n<br>";
    $body .= "--  \r\n" . PHP_EOL;
    $body .= "<p>--  \r\n</p>";

And many more. Like 200 more.

Probably the answer is a simple thing that I missed, but I'm completely lost right now.

[ Sorry for my english ]


1) What I expect from the client when it encounters the block -> that it recognizes it as a signature. That means that Gmail will put "..." while Thunderbird (in my case and with my settings) would plain cut it in the reply.

Before: After:

2) Which clients did you check? -> Gmail and TB.

3) Manual check -> Yes of course. My email has one and I'm 100% certain that it works.

What I noticed in Gmail is that, in "Show original", an ordinary mail is like this one:


    vsdfv <>

While mine is always a variation of this one:

    <br>-- =20

What I mean is that not a single line begins with the double dash but is always preceded but the previous line separator, plus it ends with =20 that Gmail uses as a return.

People are also looking for solutions to the problem: javascript - Upload multiple files using ajax


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.