Search code examples
phpphpmaileramazon-ses

How to fix send different emails to different people PHPMailer


I am going to send different emails to different people. First email sent normal but second one is waiting for 180 sec and then start to send. I couldn't find any default settings. Once sent an email others are going to POOLING and failed it.

I have different bodies and different subjects.

code 1:

    sendEmail(false, $email, $message, $subject, $dep_type);
    sendEmail(true, $email, $message_client, $subject_client);

sendEmail function :

function sendEmail($client, $email, $message, $subject, $dep_type = null)
{
    $from_mail = 'hello@example.com';

    $mail = new PHPMailer(true);

    $mail->IsSMTP();
    $mail->Host = 'email-smtp.us-east-1.amazonaws.com';

    $mail->SMTPAuth = true;
    $mail->Username = 'username';
    $mail->Password = 'password';
    $mail->From = $from_mail;
    $mail->FromName = "SenderName";
    if ($client) {
        $mail->addAddress($email);
    } else {
        $mail->addAddress('welcome@example.com');
    }
    $mail->addReplyTo($from_mail, 'name');
    $mail->isHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->send();

}

Solution

  • https://aws.amazon.com/de/premiumsupport/knowledge-center/ec2-port-25-throttle/

    Amazon EC2 throttles traffic on port 25 of all EC2 instances by default, but you can request for this throttle to be removed.