Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special Characters in 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 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 ?

like image 772
Marvin Saldinger Avatar asked Feb 19 '14 09:02

Marvin Saldinger


People also ask

Is AWS SES deprecated?

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.

Can I use Amazon SES for email marketing?

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.

Is Amazon SES an email server?

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.

How many emails can I send with Amazon SES?

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.


1 Answers

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',
            )
        ),
    )
));

?>
like image 169
Marvin Saldinger Avatar answered Oct 22 '22 17:10

Marvin Saldinger