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 protected]>',
// Destination is required
'Destination' => array(
'ToAddresses' => array('Grégory Smith <[email protected]>')
),
// 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',
)
),
)
));
?>
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 ?
To enhance the security of Amazon SES customers, beginning October 1, 2020, support for Signature Version 3 will be turned off (deprecated) in Amazon SES, and only Signature Version 4 will be supported going forward.
Amazon Simple Email Service (SES) is a cost-effective, flexible, and scalable email service that enables developers to send mail from within any application. You can configure Amazon SES quickly to support several email use cases, including transactional, marketing, or mass email communications.
Amazon SES sends email using SMTP, which is the most common email protocol on the internet. You can send email through Amazon SES by using a variety of SMTP-enabled programming languages and software to connect to the Amazon SES SMTP interface.
When your account is in the Amazon SES sandbox, you can only send 200 messages per 24-hour period, and your maximum sending rate is one message per second. When you submit a request to have your account removed from the sandbox, you can also request that your quotas are increased at the same time.
Here's the solution:
<?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 protected]>";
$to_name = base64_encode('Grégory Smith');
$to = array("=?utf-8?B?$to_name?= <[email protected]>");
$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',
)
),
)
));
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With