2017-03-11 19 views
0

私はAWSの完全なnoobです。私はAWS SESを今日構成しました。このコードを使用して受信者に電子メールを送信できます。PHPでAmazon SESを使用してhtml電子メールを送信する方法

<?php 

// Replace [email protected] with your "From" address. 
// This address must be verified with Amazon SES. 
define('SENDER', 'sender email');   

// Replace [email protected] with a "To" address. If your account 
// is still in the sandbox, this address must be verified. 
define('RECIPIENT', 'recipient email'); 

// Replace smtp_username with your Amazon SES SMTP user name. 
define('USERNAME','my username'); 

// Replace smtp_password with your Amazon SES SMTP password. 
define('PASSWORD','my password'); 

// If you're using Amazon SES in a region other than US West (Oregon), 
// replace email-smtp.us-west-2.amazonaws.com with the Amazon SES SMTP 
// endpoint in the appropriate region. 
define('HOST', 'email-smtp.us-west-2.amazonaws.com'); 

// The port you will connect to on the Amazon SES SMTP endpoint. 
define('PORT', '587');  

// Other message information            
define('SUBJECT','Hello from Driffle!'); 
define('BODY','Test Email'); 

require_once 'Mail.php'; 

$headers = array (
    'From' => SENDER, 
    'To' => RECIPIENT, 
    'Subject' => SUBJECT); 

$smtpParams = array (
    'host' => HOST, 
    'port' => PORT, 
    'auth' => true, 
    'username' => USERNAME, 
    'password' => PASSWORD 
); 

// Create an SMTP client. 
$mail = Mail::factory('smtp', $smtpParams); 

// Send the email. 
$result = $mail->send(RECIPIENT, $headers, BODY); 

if (PEAR::isError($result)) { 
    echo("Email not sent. " .$result->getMessage() ."\n"); 
} else { 
    echo("Email sent!"."\n"); 
} 

?> 

しかし、私はHTML形式のメールを送信しようとします。出力電子メールはプレーンテキストを返します。 Amazon SESを介してhtml電子メールを送信するためのソリューションを探しています。

+0

ガイドを参照してくださいhttp://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.htmlとGoogleあなたのタイトル。 –

+0

@ Fred-ii-私は電子メールを送信するためだけにそのガイドに従ったが、私の質問はイメージとカスタムフォントでHTMLとしてそれらを送信する方法です。 –

+0

完全なURLを使用してHTMLマークアップとイメージソースを使用する –

答えて

0

見つけました。

は、これらのヘッダの追加...私は少し間違ったことをしていたが、これは動作します:

'マイム・バージョン' => '1.0'、 'Content-Typeの' =>「text/htmlのを。文字セットを "ISO-8859-1" '、

とし、本文をHTMLマークアップとして提出します(できるだけシンプルにしてください - 必ずしも "ページ"である必要はありません)。

bh

0

$ headersにcontent-typeが追加されました。それは私のために働いた

require_once 'Mail.php'; 

$headers = array (
'Content-Type' => "text/html; charset=UTF-8", // <- add this line 
'From' => SENDER, 
'To' => RECIPIENT, 
'Subject' => SUBJECT); 
関連する問題