2012-04-08 2 views
0

Ich schickte E-Mail-Bestätigung Massage mit PHP Mail() -Funktion, aber es verarbeitet keine HTML-Tags. Hast du eine Idee warum?Warum wird html nicht in der E-Mail angezeigt, die ich mit der Funktion php mail() gesendet habe?

$content="Dear $name, <br /><br />Thank you for registering at NAME. Before we can activate your account one last step must be taken to confirm your email address ."; 
      $content.="<br /><br />Please note - you must complete this last step. You will only need to visit this URL once to confirm your email address.<br /><br />To complete your registration,"; 
      $content.=" please visit this URL:<br /><a href='$link1' target='_blank'> $link1 </a><br /><br /><br />"; 
      $content.="If you are still having problems signing up please contact a member of our support staff at&nbsp;<a href='mailto:[email protected]'>email</a> or contact our <a href='$link2'>customer care</a>. <br /><br />"; 
      $content.="All the best,<br />NAME<br />"; 
      mail($custArray['email'],"Please Confirm Your Email",$content); 
+2

http://php.net/manual/en/function.mail.php#example-3141 – PeeHaa

Antwort

3

Sie müssen in der Kopfzeile angeben, die dies ist eine HTML-E-Mail, so wird es als HTML interpretiert und nicht als Klartext.

http://php.net/manual/en/function.mail.php

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

$content="Dear $name, <br /><br />Thank you for registering at NAME. Before we can activate your account one last step must be taken to confirm your email address ."; 
$content.="<br /><br />Please note - you must complete this last step. You will only need to visit this URL once to confirm your email address.<br /><br />To complete your registration,"; 
$content.=" please visit this URL:<br /><a href='$link1' target='_blank'> $link1 </a><br /><br /><br />"; 
$content.="If you are still having problems signing up please contact a member of our support staff at&nbsp;<a href='mailto:[email protected]'>email</a> or contact our <a href='$link2'>customer care</a>. <br /><br />"; 
$content.="All the best,<br />NAME<br />"; 
mail($custArray['email'],"Please Confirm Your Email",$content, $headers); 
+0

Ich habe das auch versucht. Entschuldigung, dass ich das nicht in meinen Code aufgenommen habe. Hier ist, was ich '$ headers =" MIME-Version: 1.0rn "; $ headers. = "Inhaltstyp: text/html; charset = iso-8859-1rn"; $ headers. = "Von: NAME \ r \ n"; 'aber kein Glück. – guitarlass

+0

$ headers. = "Inhaltstyp: text/html; charset = iso-8859-1rn"; fehlt die Backslashes ... \ r \ n – reergymerej

3

Sie müssen wahrscheinlich die Header für eine HTML-E-Mail hinzufügen. Hier ist das Beispiel aus der PHP-Website (http://php.net/manual/en/function.mail.php):

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// Mail it 
mail($to, $subject, $message, $headers); 
+0

ich habe das auch versucht. Entschuldigung, dass ich das nicht in meinen Code aufgenommen habe. Hier ist, was ich '$ headers =" MIME-Version: 1.0rn "; $ headers. = "Inhaltstyp: text/html; charset = iso-8859-1rn"; $ headers. = "Von: NAME \ r \ n"; 'aber kein Glück. – guitarlass

1

können Sie erwägen eine externe Bibliothek mit HTML-E-Mail zu behandeln. Ich habe http://swiftmailer.org/ erfolgreich in der Vergangenheit verwendet.

0
$headers = "From: $email\r\n" . "Reply-To: $email\r\n" . "CC: $cc\r\n"; 

$message = "$logmsg \r\n\n"; 
$message .= "Name : $name \r\n\n"; 
$message .= "Email : $email \r\n\n"; 
$message .= "Phone No : $phone \r\n\n"; 
Verwandte Themen