When emails from aren’t sending properly, this usually indicates either a server configuration issue or SMTP authentication problems. Let’s explore how to resolve these email delivery challenges.
Server and SMTP Configuration
If your DigiCommerce emails aren’t being delivered, the most common cause is that your server isn’t properly configured to send emails. By default, WordPress uses the PHP mail() function, which often gets blocked by hosting providers or fails to deliver emails reliably.
Using WP Mail SMTP Plugin
The simplest solution is to use the WP Mail SMTP by WPForms plugin. This plugin helps configure your site to send emails through a proper SMTP provider, significantly improving email delivery reliability.
Configuring SMTP Without a Plugin
If you prefer not to use a plugin, you can configure SMTP settings directly in your WordPress installation. Add the following code to your theme’s functions.php file or in a site-specific plugin:
function digicommerce_smtp_mailer($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.host.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = SMTP_USERNAME;
$phpmailer->Password = SMTP_PASSWORD;
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = SMTP_USERNAME;
$phpmailer->FromName = 'DigiCommerce';
}
add_action('phpmailer_init', 'digicommerce_smtp_mailer');
Replace $phpmailer->Host by your SMTP host URL, and $phpmailer->FromName by the name you want your customers to get the email from.
Securing SMTP Credentials
For enhanced security, it’s recommended to store your SMTP credentials in your wp-config.php file rather than directly in your functions file. Add these lines to your wp-config.php:
define('SMTP_USERNAME', '[email protected]');
define('SMTP_PASSWORD', 'PASSWORD');
Replace [email protected] and PASSWORD with your actual SMTP credentials. This approach keeps your sensitive information separate from your theme or plugin files and makes it easier to update credentials when needed.
By implementing either of these solutions, your DigiCommerce plugin should begin sending emails reliably through your specified SMTP server.