amazon-ses - 初哥请教php环境下如何使用amazon SES
你好,我的网站需要发送激活邮件,目前使用的是smtp,很多都进了垃圾箱,我注册了amazon ses,但搞不得怎么使用,我想请教下php环境下如何使用amazon ses的,我见 segmentfault这个网站也是使用了这个服务
另外补充两个问题,如何设置发件人名字,如上述图片中的SegmentFault问答社区
还有就是如何发html邮件,我这样设置不行的:
$m->setMessageFromString('','我是哥This is the message body.<br><img src="http://www.AAA.com/images/indexlogo.jpg" border="0" alt="amazon-ses - 初哥请教php环境下如何使用amazon SES" >');
收到的邮件只有:我是哥This is the message body.后面的内容则没有
回复内容:
你好,我的网站需要发送激活邮件,目前使用的是smtp,很多都进了垃圾箱,我注册了amazon ses,但搞不得怎么使用,我想请教下php环境下如何使用amazon ses的,我见 segmentfault这个网站也是使用了这个服务
另外补充两个问题,如何设置发件人名字,如上述图片中的SegmentFault问答社区
还有就是如何发html邮件,我这样设置不行的:
$m->setMessageFromString('','我是哥This is the message body.<br><img src="http://www.AAA.com/images/indexlogo.jpg" border="0" alt="amazon-ses - 初哥请教php环境下如何使用amazon SES" >');
收到的邮件只有:我是哥This is the message body.后面的内容则没有
要使用ses服务首先你得确保开通了此服务,假设你已经申请开通了ses,并已经获取了"Access Key"和"Secret Key"
然后你需要先下载一个库文件http://aws.amazon.com/code/Amazon-SES...,第一次使用需要先验证你是否是发件箱的所有者,你需要执行下列代码
require_once 'ses.php'; $ses = new SimpleEmailService('Access Key Here', 'Secret Key Here'); // 这里填你需要作为发件箱的邮箱地址,这个地址必须存在,因为它会发一封邮件过去验证 print_r($ses->verifyEmailAddress('user@example.com'));
如果成功的话,会返回类似下面的内容
Array ( [RequestId] => 1b086469-291d-11e0-85af-df1284f62f28 )
这时候,登录到你刚才填写的邮箱里去,你会收到一封验证邮件,点击邮件里的验证链接即可完成验证步骤。
但是注意,这时候你还只能向自己发送邮件,不能其他任何第三方邮箱发送,因为此时你只是开发者状态,如果你需要向其他用户发送邮件,你需要向亚马逊“提出生产环境权限申请(Request Production Access)”。
点击这个链接提交申请,可能需要你填写每天发送的限额,你可以根据自己的需要申请,反正以后也是可以调整的。
需要注意的是你的限额不是一部到位的,也就是说如果你提出每天发送1万封邮件的限额,那么你第一天大概只能发送100封,然后第二天发送500封,以此类推,大概一周后你就可以发送一万封邮件了。这也是为了防止垃圾邮件制造者滥用这一服务。申请是人工审核的,所以需要等待一会,不过也没有几个小时。
当这一切都完成的了后,你就可以正常使用ses了,这里有php代码的示例,非常简单http://www.orderingdisorder.com/aws/s...
update发送中文的问题,只需要设置下编码即可
$m = new SimpleEmailServiceMessage(); $m->addTo('recipient@example.com'); $m->setFrom('user@example.com'); $m->setSubject('我是中文标题'); $m->setMessageFromString('我是中文内容.'); // 再这里设置标题和内容编码 $m->setSubjectCharset('UTF-8'); $m->setMessageCharset('UTF-8'); print_r($ses->sendEmail($m));
如果需要发送的是html内容,则需要使用setMessageFromString
的第二个参数,这是专门用来发送html内容的,比如
// 第一个参数可以留空 $m->setMessageFromString(NULL, '<h1 id="这是html的测试">这是html的测试</h1><p>只是一个测试</p>');
如果要设置发送人名称的话,可以在setFrom
的时候按照'发件人名称 '
的格式来设置,比如
$m->setFrom('Joyqi <test>');</test>
但是如果你要把上面的Joyqi换成中文的话就会出现乱码,这时候你需要自己用base64_encode
手动编码下,并指定编码格式,比如
// 编码函数 function address_encode($str) { return '=?UTF-8?B?' . base64_encode($str) . '?='; } $m->setFrom(address_encode('测试中文发件人') . ' <test>');</test>
好的,谢谢了,下载一个库文件,这个库页面打不开,是不是ses.php?如果是的话我去其他地方下载,你最后提到的例子连接里面有
很简单,很好用!
Notice: Undefined property: SimpleEmailServiceRequest::$resource in C:\xampp\htdocs\husili\email\ses.php on line 491
Warning: SimpleEmailService::sendEmail(): 60 SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in C:\xampp\htdocs\husili\email\ses.php on line 357

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
