0

我有一个触发电子邮件的 php 应用程序。现在收件人正在收到一封电子邮件,其中所有的 HTML 都打印在一个文本中。。似乎在这里找不到错误,有什么想法吗?

$user_info = get_userdata($venderid);

$shoperMail = $user_info->user_email;
$shoperName = $user_info->display_name;

$to      = $shoperMail.", info@orders.com";
$subject = "Sales Order from website";

$message  = '';
$message  = "Hi $shoperName,<br><br>";
$message .= "A Gift has been redeemed for your services.<br><br>";
$message .= "Customer: $currentuserName<br><br>";
$message .= "Redemption Amount: $$redempt<br><br>";
$message .= "Customer code:$confirmationCode<br><br>";
$message .= "To access their contact & order information, simply log in to your account & select: Gift Cards > Vendor Orders.<br><br>";
$message .= "*Once you have provided the customer with your company's voucher, certificate or online coupon code, please 'Approve' their purchase.<br><br>";
$message .= "Log in: <a href='".$url."/login/'>http://test.com</a><br><br>";
$message .= "If you have any questions, please don't hesitate to contact me.<br><br>";
$message .= "Test test<br>order Gift Cards<br><i>doing cool stuff.</i><br><br>toll free: 866.test x.tes x 9<br><a href='http://www.test.com/'>Test.com</a>,<br><a href='http://www.facebook.com/test/'>facebook.com/test</a><br><a href='http://twitter.com/test/'>twitter.com/test</a><br><br><br>" ;
$message .= "**The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this email in error, please contact the sender immediately by return electronic transmission and then immediately delete this transmission, including all attachments, without copying, distributing or disclosing same. ";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: ".$shoperMail."\r\n";
$headers .= "From: orders@prders.com\r\n";

mail($to,$subject,$message,$headers);
4

3 回答 3

0

You need to set the HTML content type, example from the Codex:

add_filter( 'wp_mail_content_type', 'my_set_html_content_type' );
wp_mail( 'me@example.net', 'The subject', '<p>The <em>HTML</em> message</p>' );
remove_filter( 'wp_mail_content_type', 'my_set_html_content_type' ); // reset content-type

Filter callback:

function my_set_html_content_type()
{
    return 'text/html';
}
于 2013-04-25T19:01:05.930 回答
0

我已将您的代码嵌入到我通常使用的相同 html-mail-markup 中。

试试这个:

// Getting info    
$user_info = get_userdata($venderid);
$shoperMail = $user_info->user_email;
$shoperName = $user_info->display_name;
$to = $shoperMail.", info@orders.com";

// HTML
$message  = '';
$message  = "Hi $shoperName,<br><br>";
$message .= "A Gift has been redeemed for your services.<br><br>";
$message .= "Customer: $currentuserName<br><br>";
$message .= "Redemption Amount: $$redempt<br><br>";
$message .= "Customer code:$confirmationCode<br><br>";
$message .= "To access their contact & order information, simply log in to your account & select: Gift Cards > Vendor Orders.<br><br>";
$message .= "*Once you have provided the customer with your company's voucher, certificate or online coupon code, please 'Approve' their purchase.<br><br>";
$message .= "Log in: <a href='".$url."/login/'>http://test.com</a><br><br>";
$message .= "If you have any questions, please don't hesitate to contact me.<br><br>";
$message .= "Test test<br>order Gift Cards<br><i>doing cool stuff.</i><br><br>toll free: 866.test x.tes x 9<br><a href='http://www.test.com/'>Test.com</a>,<br><a href='http://www.facebook.com/test/'>facebook.com/test</a><br><a href='http://twitter.com/test/'>twitter.com/test</a><br><br><br>" ;
$message .= "**The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this email in error, please contact the sender immediately by return electronic transmission and then immediately delete this transmission, including all attachments, without copying, distributing or disclosing same. ";

// Subject
$subject = "Sales Order from website";

// Header 
$innerboundary ="=_".time()."_=";
$header ="MIME-Version: 1.0\n"; 
$header.="To: ".$to."\n"; 
$header.="From: orders@prders.com\n";
$header.="Reply-To: orders@prders.com\n";
$header.="X-Mailer: kmPHP-Mailer\n"; 
$header.="Content-Type: multipart/alternative;\n\tboundary=\"".$innerboundary."\"\n";

// Body
$body.="\n--".$innerboundary."\n"; 
$body.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n"; 
$body.="Content-Transfer-Encoding: base64\n\n"; 
$body.=chunk_split(base64_encode(($message)))."\n\n"; 
$body.="\n--".$innerboundary."--\n"; 
$body.="\n\n"; 

// Send
mail($shoperMail,$subject,$body,$header);
于 2013-04-25T21:18:44.230 回答
0

重申上面的 Marc B 评论

不要手动构建 MIME 电子邮件。使用phpmailerswiftmailer。他们为您自动完成这一切,您所要做的就是提供 html。

这样做将使您更容易以不同的方式解决问题。

于 2013-04-25T21:33:52.797 回答