Я хочу отправить вложение с помощью простой почтовой службы AWS - PHP SDK. В настоящее время у меня есть этот код:
<code>require 'composer/vendor/autoload.php';
use Aws\Ses\SesClient;
$client = SesClient::factory(array(
'credentials' => array(
'key' => '12345689',
'secret' => 'abcdefghijklmno',
),
'region' => 'us-east-1',
'version' => 'latest',
));
//Now that you have the client ready, you can build the message
$msg = array();
$msg = array(
'Source'=> 'test@test.com',
'Destination'=>array(
'ToAddresses'=>array('example@example.com'),
),
'Message'=>array(
'Subject'=>array(
'Data'=>'Text only subject',
'Charset' => 'UTF-8',
),
'Body'=>array(
'Text'=>array(
'Data'=>'Text only subject',
'Charset' => 'UTF-8',
),
'Html'=>array(
'Data'=>'Text only subject but in HTML',
'Charset' => 'UTF-8',
),
),
),
'Content-Disposition' => array(
1 => array(
'Name' => 'filename1.jpg',
'Path' => 'https://cdn-attachments.timesofmalta.com/1117ea83f470eeb110e2ee2cad50fada0abc47b3-1571995498-5db2bf6a-960x640.jpg',
'Mime'=>'image/jpg',
),
),
);
try{
$result = $client->sendEmail($msg);
//save the MessageId which can be used to track the request
$msg_id = $result->get('MessageId');
echo('MessageId:'. $msg_id);
//view sample output
print_r($result);
} catch (Exception $e) {
//An error happened and the email did not get sent
echo($e->getMessage());
}
//view the original message passed to the SDK
echo '<pre>';
print_r($msg);
echo '
';
Письмо отправлено, но вложение не доставлено. До сих пор я не нашел никакой документации для включения вложения в массив, как указано выше. Я позаимствовал эту часть из другой документации. Это то, что я пытался.
1 => array(
'Name' => 'filename1.jpg',
'Path' => 'https://cdn-attachments.timesofmalta.com/1117ea83f470eeb110e2ee2cad50fada0abc47b3-1571995498-5db2bf6a-960x640.jpg',
'Mime'=>'image/jpg',
),
Пожалуйста, это правильно, так как не работает.
TIA