dot(.)s are missing here & there in the mail html while sending PEAR Mail_Mime emails dot(.)s are missing here & there in the mail html while sending PEAR Mail_Mime emails php php

dot(.)s are missing here & there in the mail html while sending PEAR Mail_Mime emails


I'm pretty sure this is caused by dot-stuffing; as the dot is used as a special indicator in emails. You can read about this in the rfc where it says (emphasis added):

To allow all user composed text to be transmitted transparently, the following procedures are used:

  • Before sending a line of mail text, the SMTP client checks the first character of the line. If it is a period, one additional period is inserted at the beginning of the line.
  • When a line of mail text is received by the SMTP server, it checks the line. If the line is composed of a single period, it is treated as the end of mail indicator. If the first character is a period and there are other characters on the line, the first character is deleted.

It seems the client you're using to compose these emails does not implement the first procedure, while the server it sends the mail to does implement it; leading to dots disappearing.

The fix would be to make your client implement the padding.


Use PHPMailer, it will make life a lot easier.


Here is the example of it -

     // Set up the headers that will be included in the email.    $recipient = 'someemail@gmail.com';    $from = 'someemail1@gmail.com';    $headers = array(      'To'            => $recipient,      'From'          => $from,      'Return-Path'   => $from,      'Reply-To'      => $replyto, //based on your need      'Subject'       => $subject,      'Errors-To'     => '<<a href="mailto:errors@example.com">errors@example.com</a>>',      'MIME-Version'  => '1.0',    );    // Set up parameters for both the HTML and plain text mime parts.    $textparams = array(      'charset'       => 'utf-8',      'content_type'  => 'text/plain',      'encoding'      => 'quoted/printable',    );    $htmlparams = array(      'charset'       => 'utf-8',      'content_type'  => 'text/html',      'encoding'      => 'quoted/printable',    );    // Create the email itself. The content is blank for now.    $email = new Mail_mimePart('', array('content_type' => 'multipart/alternative'));    // Add the text and HTML versions as parts within the main email.    $textmime = $email->addSubPart($textbody, $textparams);    $htmlmime = $email->addSubPart($htmlbody, $htmlparams);    // Get back the body and headers from the MIME object. Merge the headers with    // the ones we defined earlier.    $final = $email->encode();    $final['headers'] = array_merge($final['headers'], $headers);    // Perform the actual send.    $smtp_params = array();    $smtp_params['host'] = '127.0.0.1';    $smtp_params['port'] = '25';    $smtp_params['persist'] = TRUE;    $mail =& Mail::factory('smtp', $smtp_params);    $status = $mail->send($recipient, $final['headers'], $final['body']);