无法从Amazon EC2托管网站发送电子邮件

时间:2015-03-02 04:38:21

标签: php email amazon-web-services amazon-ec2 amazon-ses

我安装了postfix以启用SMTP

我按照所有步骤操作..我能够通过我的经过验证的电子邮件地址收到我的电子邮件,直到thrusday

但他们是空白的。

突然它在星期六停止了

php代码的执行方式与先前执行

的方式相同
    <?php
    header('Content-type: application/json');
    $status = array(
        'type'=>'success',
        'message'=>'Email sent!'
    );

    $name = @trim(stripslashes($_POST['name'])); 
    $email = @trim(stripslashes($_POST['email'])); 
    $subject = @trim(stripslashes($_POST['subject'])); 
    $message = @trim(stripslashes($_POST['message'])); 

    $email_from = $email;
    $email_to = 'abc@gmail.com';


    $body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

    $headers = "From: mail <$email_from>\r\n";
$headers .= "MIME-Version: 1.0" ."\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $success = mail($email_to, $subject, $body,$header);
    echo json_encode($status);
    die; 

请建议

1 个答案:

答案 0 :(得分:1)

AWS throttles emails sent through EC2 servers。节流率尚未公布。某些EC2 IP地址也可能存在黑名单问题。

最终导致的是&#34;使用SES&#34;。

Here's an unofficial how to bolt SES on,但更好的选择是use the AWS PHP SDK to send email to SES