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

前端 未结 3 415
-上瘾入骨i
-上瘾入骨i 2021-01-01 23:37

I am sending a mail using PEAR\'s mail and mail_mime packages and sample code as below:

$sendStart=array();
require_once(\'Mail.php\');
require_once(\'Mail/m         


        
3条回答
  •  無奈伤痛
    2021-01-02 00:02

    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'     => '<errors@example.com>',
          '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']);
    

提交回复
热议问题