I was just wondering if infinityfree for any reason blocks outgoing emails through smtp via sendinblue. I get this error when I enter my email address into the “mailing list” html form. it’s not a mailing list, it sends 1 email then never contacts you again unless you re-enter your details. I’m really new to this and don’t know why this is happening. could anyone help me understand why the 502 error is occuring?
Thanks
As far as I am aware, Sendinblue SMTP is not blocked.
Can you try turning on display errors in the control panel (Under PHP config), and turn on any debug logs on the SMTP platform you are using (I am assuming it is PHPMailer).
<?php
use SendinBlue\Client\Configuration;
use SendinBlue\Client\Api\TransactionalEmailsApi;
use SendinBlue\Client\Model\SendSmtpEmail;
// Configure API key authorization: api-key
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'MY_API_KEY_HIDDEN');
$api_instance = new SendinBlue\Client\Api\TransactionalEmailsApi(
new GuzzleHttp\Client(),
$config
);
$name = $_POST['name'];
$email = $_POST['email'];
$send_smtp_email = new \SendinBlue\Client\Model\SendSmtpEmail();
$send_smtp_email['subject'] = 'Test Email';
$send_smtp_email['htmlContent'] = "<h1>Hello $name,</h1><p>Thank you for signing up to the Killer Nun Mailing List! We hope you enjoy your time with us.</p>";
$send_smtp_email['sender'] = ['name' => 'J.E.Fievez', 'email' => '[email protected]'];
$send_smtp_email['to'] = ['email' => $email, 'name' => $name];
try {
$result = $api_instance->sendTransacEmail($send_smtp_email);
// Redirect to thank you page if email is sent successfully
header('Location: thank_you.php');
} catch (Exception $e) {
echo 'Exception when calling TransactionalEmailsApi->sendTransacEmail: ', $e->getMessage(), PHP_EOL;
}
//API KEY => MY_API_KEY_HIDDEN
?>
Just to note: since you’re using Sendinblue’s API client, you’re probably sending email using their own HTTP API, not SMTP. Most email sending platforms have their own APIs in addition to standard SMTP, which is usually more efficient and provides some other options.
We don’t block either SMTP or using most third party APIs. But even if SMTP were blocked, you would not be affected.