• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

problem with sending email with php

the problem is that i send my email with headers, subject and content on right address , but everything seems to be in email mixed up.
here is my code:
-----------------------------------------------------------------------
$headers  = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
      $headers .= 'From: '.$settings_extension['sumbit_email'].'' . "\r\n";
      
      $subject = "THE PROBLEM";
    $content = "<br><br>";
      
      
         mail("mymail@example.com", $subject , $content , $headers);
--------------------------------------------------
everything comes like html, it shows no newline , it shows <br><br> tags in email
how can i fix this
hest regards
0
galic1987
Asked:
galic1987
2 Solutions
 
hernst42Commented:
use a class which encodes everything correctly like:
http://swiftmailer.sf.net
http://phpmailer.sf.net
0
 
MikkkCommented:
This is the way I do it and works fine (be carefull to fill all variables ($from,$text...) as you wish:

$uid = strtoupper(md5(uniqid(time())));
$body="";
$header = "From: \"Me\" <no-reply@me.com>\nReply-To: $from\n";
if ($bcc!="") $header .= "Bcc: $bcc\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; \n      boundary=$uid\n";

$body .= "--$uid\n";
$body .= "Content-Type: text/html\n";
$body .= "Content-Transfer-Encoding: 8bit\n\n";
$body .= "$text\n";

$body .= "--$uid\n";

mail($to, $subject, $body, $header);
0
 
galic1987Author Commented:
it seems that i needed only to delete the "\r" because of server settings
thanks
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now