如何发送带有特殊字符的Mandrill消息? [英] How to send Mandrill message with special characters?
问题描述
我正在使用Mandrill向我们的会员发送邮件.
发送普通短信非常完美.
但是带有特殊字符(ä,ë,ï,ö,ü,€,...)的消息不会附加在Mandrill的'html' =>
变量中.
I am using Mandrill to send mails to our members.
Sending a normal text message works perfect.
But a message with special characters (ä,ë,ï,ö,ü,€,...) will not be attached in Mandrill's 'html' =>
variable.
有人可以告诉我如何通过Mandrill发送带有特殊字符的消息吗?
Can anyone tell me how to send a message with special characters through Mandrill?
我试图用str_replace
和preg_replace
编辑$message_content
变量,到目前为止没有一个起作用.
I tried to edit the $message_content
variable with str_replace
and preg_replace
, none worked so far.
当我输入消息内容时使用ï
和€
时,它可以完美工作.但是当按下提交"按钮时,我似乎无法更改它.
When I use ï
and €
when typing the message content, it works perfect. But I can't seem to change this when the submit button is pressed.
这是我的代码:
<?
if(isset($_POST['submit']) {
$subject = $_POST['subject'];
$from_name = $_POST['from_name'];
$from_email = $_POST['from_email'];
$message_content = nl2br($_POST['message_content']);
$mail_to_members = array();
$mail_to_members[] = array('email' => 'name@domain.com');
$mail_to_members[] = array('email' => 'name@domain.com');
//Get Mandrill API
require_once './include/src/Mandrill.php';
$mandrill = new Mandrill('API-key');
//Create mail
$message = array(
'subject' => $subject,
'from_name' => $from_name,
'from_email' => $from_email,
'html' => $message_content,
'to' => $mail_to_members,
);
$mandrill->messages->send($message);
}
?>
推荐答案
我们遇到了完全相同的问题,并使用以下方法解决了该问题:
We had this exact same problem and we solved it using the following:
mb_convert_encoding($message_content, 'UTF-8', 'ASCII');
它将内容从ASCII转换为UTF-8.
It converts your content from ASCII to UTF-8.
这篇关于如何发送带有特殊字符的Mandrill消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!