Amazon SES中的特殊字符 [英] Special Characters in Amazon SES
本文介绍了Amazon SES中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用适用于PHP的AWS开发工具包( https://github.com/aws/aws -sdk-php )以使用Amazon SES发送电子邮件。
这是代码:
I'm using AWS SDK for PHP (https://github.com/aws/aws-sdk-php) to send emails using Amazon SES. Here's the code:
<?php
require 'vendor/autoload.php';
use Aws\Ses\SesClient;
$client = SesClient::factory(array(
'key' => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'region' => 'eu-west-1'
));
$result = $client->sendEmail(array(
// Source is required
'Source' => 'Télécom Co <email@address.com>',
// Destination is required
'Destination' => array(
'ToAddresses' => array('Grégory Smith <another_email@address.com>')
),
// Message is required
'Message' => array(
// Subject is required
'Subject' => array(
// Data is required
'Data' => 'The subject',
'Charset' => 'utf-8',
),
// Body is required
'Body' => array(
'Text' => array(
// Data is required
'Data' => 'The message',
'Charset' => 'utf-8',
)
),
)
));
?>
问题在于,电子邮件客户端中的Télécom看起来像T�l�com,
The problem is that in the email clients "Télécom" appears like "T�l�com" and "Grégory" like "Gr�gory".
这个问题有解决方案吗?
Are there any solutions for this problem ?
推荐答案
这是解决方案:
<?php
require 'vendor/autoload.php';
use Aws\Ses\SesClient;
$client = SesClient::factory(array(
'key' => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'region' => 'eu-west-1'
));
$from_name = base64_encode("Télécom Co");
$from = "=?utf-8?B?$from_name?= <email@address.com>";
$to_name = base64_encode('Grégory Smith');
$to = array("=?utf-8?B?$to_name?= <another_email@address.com>");
$result = $client->sendEmail(array(
// Source is required
'Source' => $from,
// Destination is required
'Destination' => array(
'ToAddresses' => $to
),
// Message is required
'Message' => array(
// Subject is required
'Subject' => array(
// Data is required
'Data' => 'The subject',
'Charset' => 'utf-8',
),
// Body is required
'Body' => array(
'Text' => array(
// Data is required
'Data' => 'The message',
'Charset' => 'utf-8',
)
),
)
));
?>
这篇关于Amazon SES中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文