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 = 'mail@mydomain.com';
$mail->Password = 'EMAILPASSWORD';
Replace xxxxxxxNNNNN with your correct ID that you can find in the address bar while login in cPanel
Important (!): If you use cPanel email accounts to send emails via PHPMailer, be sure email routing set to LOCAL.
$mail->isSMTP();
$mail->Host = 'smtpout.secureserver.net';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = 'your@email';
$mail->Password = 'EMAILPASSWORD';
Important (!): If you use Professional email accounts to send emails via PHPMailer, be sure email routing set to REMOTE.
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 = 'mydomain.com';
$mail->DKIM_selector = 's123';
$mail->DKIM_identity = 'mail@mydomain.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;
}
By default WordPress mailer works with PHPMailer like with PHP mailer what can occur to delivery issues. To prevent it you need to set-up SMTP settings using some plugin or just easly modify functions.php
file of your template by adding PHPMailer custom initialization. Here is an example of how to add server and DKIM settings for GoDaddy/HostBrook accounts:
add_action( 'phpmailer_init', 'phpmailer_config' );
function phpmailer_config( $phpmailer ) {
// Server settings
$phpmailer->isSMTP();
$phpmailer->Host = '{xxxxxxxNNNNN}.prod.iad2.secureserver.net';
$phpmailer->Port = '587';
$phpmailer->SMTPSecure = 'SSL';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = '{EMAIL_FROM}';
$phpmailer->Password = '{EMAIL_PASSWORD}';
$phpmailer->From = '{EMAIL_FROM}';
$phpmailer->FromName = '{NAME_FROM}';
// DKIM settings
$phpmailer->Encoding = 'quoted-printable';
$phpmailer->DKIM_domain = '{DOMAIN_NAME}';
$phpmailer->DKIM_selector = '{SELECTOR}';
$phpmailer->DKIM_passphrase = '';
$phpmailer->DKIM_identity = $phpmailer->From;
$phpmailer->DKIM_private_string =
'-----BEGIN RSA PRIVATE KEY-----
{PRIVATE_KEY}
-----END RSA PRIVATE KEY-----';
}