How to format email using SMTP

PhilipH

New Member
I'm trying to send formatted email with php smtp authentication, but for some reason(s) \[code\]\n\[/code\], \[code\]\r\n\[/code\] and \[code\]PHP_EOL\[/code\] can not format the message, hence everything appears on a line. Below is what I've tried\[code\]$order .= "Title : {$title}" . PHP_EOL."Author : {$author}" . PHP_EOL."ISBN : {$isbn}" . PHP_EOL."Publisher : {$publisher}" . PHP_EOL."Supplier : {$supplier}\nQuantity : {$qty}\r\n \[/code\]The variable \[code\]$order\[/code\] contains the body of the email.Here is part of my \[code\]sendMail()\[/code\] function\[code\]$from = "{$sender_name} <{$sender}>";$to = $reciever." <$email>";$subject = $subj;$body = $msg;$host = "mail.thekingsbooks.com"; $username = "[email protected]";$password = "password";$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);\[/code\]The sent mail looks like this\[code\]Ordered items\r\nTitle : A Retreat With Pope John Paul II: Be Not Afraid (Retreat With-- Series)\r\nAuthor : \r\nISBN : 0867164204\r\nPublisher : \r\nSupplier : \r\n\r\n Quantity : 6\r\n\r\n \[/code\]Any suggestion on how to format the email body? Thanks
 
Back
Top