2017-03-11 4 views
0

나는 AWS의 완전한 멍청한 생활자입니다. 오늘 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', '콘텐츠 유형'=> '텍스트/html로; charset = "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); 
관련 문제