Sending Raw via api

0

We need to be able to personalise headers which seems to mean we need to send a raw sender - is there a guide on how to do this in AWS - ideally using PHP?

질문됨 일 년 전221회 조회
1개 답변
0
use Aws\Ses\SesClient;

$client = SesClient::factory(array(
    'version' => 'latest',
    'region' => 'us-west-2', // replace with your desired region
    'credentials' => array(
        'key' => 'YOUR_AWS_ACCESS_KEY_ID',
        'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
    ),
));

// Set the raw message content
$rawMessage = "From: sender@example.com\r\n";
$rawMessage .= "To: recipient@example.com\r\n";
$rawMessage .= "Subject: Test email\r\n";
$rawMessage .= "Content-Type: text/html; charset=us-ascii\r\n\r\n";
$rawMessage .= "<h1>This is a test email</h1>";

$result = $client->sendRawEmail(array(
    'RawMessage' => array(
        'Data' => base64_encode($rawMessage),
    ),
));

// Check for errors
if (!$result['MessageId']) {
    echo "Error sending email: " . $result['Error']['Message'];
} else {
    echo "Email sent successfully";
}

profile picture
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠