Vipin Sharma
Vipin Sharma

Reputation: 11

Unable to send emails from Amazon EC2 hosted website

I installed postfix in order to enable SMTP

i followed all the steps.. i was able to receive my emails on my verified email address till thrusday

but they were blank.

suddenly it stopped on saturday

the php code is executing in the same way as it use to execute earlier

    <?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 = '[email protected]';


    $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; 

please suggest

Upvotes: 0

Views: 418

Answers (1)

300D7309EF17
300D7309EF17

Reputation: 24643

AWS throttles emails sent through EC2 servers. The throttle rate isn't published. Some EC2 IP addresses may have problems with blacklists too.

Ultimately what this leads to is "use SES".

Here's an unofficial how to bolt SES on, but the better option is to use the AWS PHP SDK to send email to SES.

Upvotes: 1

Related Questions