Fredy31 Fredy31 - 3 months ago 21
HTML Question

Random 15 letter code after email

I have a 15 letter code that seems to add itself at the end of emails I send.

enter image description here

This code seems to change every email batch I send (if I send multiple emails via a loop, they all have the same code, but next time I send multiple emais, the code is different) and the code always seem to be 15 characters.

So does anybody know where this code might be coming from, and how to prevent it?

I'm using the default PHP mail() function.

Edit:

Heres a snippet of the code generating the Email.

$boundary = uniqid('np');
$headers = 'From: This.Site <no-reply@This.Site>' . "\r\n" .
'Reply-To: no-reply@This.Site' . "\r\n" .
"MIME-Version: 1.0" . "\r\n" .
"Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n".
'X-Mailer: PHP/' . phpversion();

mail($email, 'Subject - '.$title.' - Client Name', create_notif_email($name, $compagnieFrom, $title, $link, $boundary), $headers);

function create_notif_email($name, $compagnieFrom, $title, $link, $boundary){
$urlSite = get_bloginfo('url');
$html = '';
$html .= file_get_contents(__DIR__.'/plaintext.txt');
$html .= "\r\n\r\n--" . $boundary . "\r\n";
$html .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
$html .= file_get_contents(__DIR__.'/plaintext.txt');
$html .= "\r\n\r\n--" . $boundary . "\r\n";
$html .= "Content-type: text/html;charset=utf-8\r\n\r\n";
$html .= file_get_contents(__DIR__.'/mail.html');
$html .= $boundary;
$html = str_replace('[NOM]', $name, $html);
$html = str_replace('[FROM]', $compagnieFrom, $html);
$html = str_replace('[TITLE]', $title, $html);
$html = str_replace('[LINK]', '<a href="'.$link.'">'.$link.'</a>', $html);
$html = str_replace('[URLSITE]', $urlSite, $html);
return $html;
}


mail.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Nouveau poste pour vous! - [TITLE] - Bestaff</title>
</head>
<body style="width:100%; margin:0; padding:0; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;">

<!-- body wrapper -->
<table cellpadding="0" cellspacing="0" border="0" style="margin:0; padding:0; width:100%; line-height: 100% !important;">
<tr>
<td valign="top">
<!-- edge wrapper -->
<!-- ///////////////////////////////////////////////////// -->

<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="20"></td>
<td valign="top" style="vertical-align: top; text-align:left;">
<br /><img src="[URLSITE]/images/image.png" alt="Bestaff.in" title="Bestaff.in"/><br />
<div style="font-family:Arial, sans-serif; font-size:14px; line-height:18px;">
<br /><i>English version follows</i><br /><br />
Bonjour [NOM],<br /><br />
[FROM] [TITLE].<br /><br />
[LINK]<br /><br />
Bonne chance!<br /></br>
<i style="font-style=12px"></i>
<br />&nbsp;<hr /><br />
Hello [NOM],<br /><br />
[FROM][TITLE].<br /><br />
[LINK]<br /><br />
Good luck!<br /></br>
<i style="font-style=12px"></a></i><br />
&nbsp;
</div>
</td>
<td width="20"></td>
</tr>
</table>

</td>
</tr>
</table>
<!-- / page wrapper -->
</body>
</html>


and plaintext.txt

English version follows

Bonjour [NOM],
[FROM][TITLE].
[LINK]
Bonne chance!

Hello [NOM],
[FROM][TITLE].
[LINK]
Good luck!

Answer

Boundary id typically start with double dash and are followed immediatly by a line break Try this.... Change

 $html .= $boundary;

to

$html .= '--'.$boundary.'
';

source:https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html