PHP code example of xjdata / aliyun-open-api-dm

1. Go to this page and download the library: Download xjdata/aliyun-open-api-dm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xjdata / aliyun-open-api-dm example snippets


/**
 * 访问信息
 */
$config = [
	'AccessKeyId'=>'<your access_key_id>',
	'AccessKeySecret'=>'<your access_key_secret>',
];

/**
 * 配置网关
 */
$endpoint = new Endpoint('cn-hangzhou', EndpointConfig::getRegionIds(), EndpointConfig::getProductDomains());
EndpointProvider::setEndpoints([ $endpoint ]);

/**
 * 授权资料
 */
$profile = DefaultProfile::getProfile('cn-hangzhou', $config['AccessKeyId'], $config['AccessKeySecret']);


/**
 * 请求对象
 */
$request = new \Aliyun\Dm\Request\SingleSendMailRequest();
$request->setAccountName("[email protected]");
$request->setFromAlias("某某");
$request->setAddressType(1);
$request->setTagName("youtagname");
$request->setReplyToAddress("true");
$request->setToAddress("[email protected]");
$request->setSubject("邮件主题");
$request->setHtmlBody("邮件正文");
$response = $client->getAcsResponse($request);
var_dump($response);