HostBrook recommends using PHPMailer for email sending from PHP.
Please see below PHPMailer settings and PHP code example that works on our servers.
Summary of this page:
$mail->isSMTP();
$mail->Host = 'xxxxxxxNNNNN.prod.iad2.secureserver.net';
$mail->SMTPSecure = 'SSL';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'your@email';
$mail->Password = 'EMAILPASSWORD';
Replace xxxxxxxNNNNN with your correct ID that you can find in the address bar while login in cPanel
$mail->isSMTP();
$mail->Host = 'smtpout.secureserver.net';
$mail->Port = 80;
$mail->SMTPAuth = true;
$mail->Username = 'your@email';
$mail->Password = 'EMAILPASSWORD';
Although GoDaddy doesn't provide DKIM signature option for both cPanel and Workspace emails (this option is available for Microsoft 365 email plan only) you still can send emails with DKIM signature using PHPMailer as an email sender. This can decrease the probability to get your emails into the spam box.
If you would like to add DKIM signature to your emails that sent via PHPMailer, please follow the steps below.
Follow the link https://tools.socketlabs.com/dkim/generator
Generate Public and Private Keys using any selector you want. Save them as well as a host name value for your DNS record.
Add TXT record in the domain DNS. Use the HOST value and Public Key that were provided in the prevous step. Added record should looks like this:
You have to set three values for PHPMailer: Domain, Email, Selector and Private Key.
You have two options to add Private Key:
Set path to file "private.key" with Private Key record:
$mail->DKIM_private = 'path/to/your/private.key';
or:
Add Private Key directly
$mail->DKIM_private_string = 'your-private-key';
Here is an example of the code for the second option:
$mail->DKIM_domain = 'microsoft.com';
$mail->DKIM_selector = 's221';
$mail->DKIM_identity = 'mail@microsoft.com';
$mail->DKIM_private_string = '-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAu6VpFUbCBwlB+7qw9qjf1pAqGppJIUqsMF/n7f3JGI7b85mW
...
7ZorWXSeJGuLpyn2onMSH7X2o8Ku9KTrJtENzAOghCLt0pQeMW2cF24=
-----END RSA PRIVATE KEY-----';
Here some online tools to check your emails:
Check if DKIM record is shown and has a correct format:
Test the Spammyness of your Emails:
The PHP code below uses cPanel email server settings and DKIM signature.
Just replace values in {} brackets with your data to make it work:
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once '/PHPMailer/Exception.php';
require_once '/PHPMailer/PHPMailer.php';
require_once '/PHPMailer/SMTP.php';
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = '{xxxxxxxNNNNN}.prod.iad2.secureserver.net';
$mail->SMTPSecure = 'SSL';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = '{EMAIL_FROM}';
$mail->Password = '{EMAIL_PASSWORD}';
$mail->DKIM_domain = '{DOMAIN_NAME}';
$mail->DKIM_selector = '{SELECTOR}';
$mail->DKIM_identity = {EMAIL_FROM};
$mail->DKIM_private_string = '-----BEGIN RSA PRIVATE KEY-----
{PRIVATE_KEY}
-----END RSA PRIVATE KEY-----';
$mail->isHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Encoding = 'base64';
$mail->setFrom({EMAIL_FROM}, {NAME_FROM});
$mail->Subject = {MAIL_SUBJECT};
$mail->addAddress('{EMAIL_TO}', '{NANE_TO}');
$mail->Body = '{EMAIL_HTML_BODY}';
$mail->AltBody = '{EMAIL_PLAIN_TEXT_BODY}';
try {
$mail->send();
// Message has been sent successfully
} catch (Exception $e) {
// Error occurred during email sending
echo 'Error occurred: '.$mail->ErrorInfo;
}