Adding a Content Type to Pear Mail

I assume that for message types of type text / html format for content, the default font style and client / user machine size are set. User Pear Mail, how to add to the content type. All the examples I posted show only adding a content type with mime attachments.

Also, if there is another way to make and by default send the default font mail clients and font sizes of email clients, I would like to know.

I would like to add

$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

current postal code

 $from = " sys@test.com "; $to = $SendTo; $subject = "Contact : " . $uxGlobalLocation; $body = $Bodycopy; $host = "mail.set.co"; $username = " donotreply@set.co "; $password = "empty00"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { header ('Location: /'); exit(); } 

EDIT Possible answer

 $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Content-Type' => 'text/html; charset=iso-8859-1', 'MIME-Version' => '1.0'); 
+4
source share
1 answer

It works. It took me endlessly to figure out that the last element in the $ headers array should have \ r \ n \ r \ n

 <?php require_once "Mail.php"; $from = "Web Master < master@example.com >"; $replyto = "Education Dept. < education@example.com >"; $to = "< mytest@example.com >"; $subject = "Test email using PHP SMTP"; $body = "<p>Test HTML</p><p>This is a test email message</p>"; $host = "smtp.example.com"; $username = " master@example.com "; $password = "****************"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Reply-To' => $replyto, 'MIME-Version' => "1.0", 'Content-type' => "text/html; charset=iso-8859-1\r\n\r\n"); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> 
+8
source

Source: https://habr.com/ru/post/1410781/


All Articles