124 1

Hello, my website needs to send an activation email, which is currently using smtp, many of them are in the trash bin, and I've registered amazon ses, but I'm not sure how to use it under the php environment.

Also added two issues, how to set the sender name, such as SegmentFault问答社区 in the image above

And how to send an html message, I can't set it up:

$m->setMessageFromString('','我是哥This is the message body.<br><img src= border=0>');

I've received the message only: I'm this is the message body. I don't have the following content.

4 Answers

106 0

To use the ses service first you've to make sure that you've opened up the service, assuming that you've already applied the ses and got the"access key"and"secret key".".

And then you need to download a library file http://aws. Amazon. com/code/Amazon-SES., the first time you need to verify that you're the owner of the outbox, you need to execute the following code.

require_once 'ses.php';
$ses = new SimpleEmailService('Access Key Here', 'Secret Key Here');

If successful, you'll return the following contents

 [RequestId] => 1b086469-291d-11e0-85af-df1284f62f28

At this point, log in to the mailbox you just filled in, and you'll receive a verification message and click the verification link in the message to complete the verification steps.

, but at this point you can only send mail to yourself, not any other third party email, because you're just a developer status, if you need to send mail to another user, you need to"put forward the production environment permission application ( request production access )".

By clicking on this link to submit the application, you may need to fill out the quota you send every day, and you may be able to adjust it after you.

It's important to note that your limit isn't in place. If you put a limit on sending 1 million emails every day, you'll probably be able to send 100, then send 500 seal. This is also meant to prevent spam makers from abuse of this service. Application is, so wait for a while, but there are no hours.

After all this is done, you'll be able to use , and here are examples of php code, simple http://www. Orderingdisorder. com/aws/s..


Send chinese questions, only need to set up code.

$m = new SimpleEmailServiceMessage();

If you need to send html content, you need to use the second parameter of setMessageFromString, which is specifically used to send html content, such as

$m->setMessageFromString(NULL, '<h1>这是html的测试</h1><p>只是一个测试</p>');

If you want to set the sender name, you can follow setFrom. '发件人名称 <邮箱地址>' Format to set, such as

$m->setFrom('Joyqi <>');

But if you want to convert the above joyqi to chinese, then you'll need to code yourself with base64_encode, and specify the coding format, such as

function address_encode($str) {
 return '=?UTF-8?B?'. base64_encode($str). '?=';
$m->setFrom(address_encode('测试中文发件人'). ' <>');