1. Home
  2. Docs
  3. Advanced Topics
  4. Emails are not being sent to the users

Emails are not being sent to the users

If you are facing the issue of emails not being sent to the users or the admin even after successful quiz/survey completion then it might be due to any of the following reasons:

To fix this issue, you need to set up SMTP on your server. SMTP allows you to send and receive mail messages. There are two ways to set up SMTP on your server.

Method 1: Setup SMTP using a WordPress Plugin

This method is the easiest, you would need to download the WP Mail SMTP plugin. The plugin allows you to send WordPress emails using the SMTP server.

You would need to install and activate the WP Mail SMTP plugin. Next, you need to configure it by visiting Settings > WP Mail SMTP

To use WP Mail SMTP, you must first enter your SMTP settings. The first part of the configuration will be the same regardless of the hosting you’re using.

  • From Email – The email address from which the WordPress emails will be sent.
  • From Name – This is the name that will be used when sending emails. You can enter the title of your website as the from name.
  • Mailer – Select ‘Other SMTP’ here because you will be sending emails through your host’s SMTP server.
  • Return Route – Check this box if you want to be notified of the delivery or bounced message.

If you want to keep using your host, choose Other SMTP and enter the SMTP server settings provided by your hosting provider.

  • SMTP Host – The SMTP host address is supplied by your hosting provider.
  • Encryption – The method of encryption used by your mail server to send emails. TLS is usually used.
  • SMTP Port – The SMTP port is used by the outgoing mail server.
  • Auto TLS – This option should be enabled.
  • Authentication – Must be Enabled
  • SMTP Username – Typically, this is the email address you use to send emails.
  • SMTP Password – This is the password for the email account from which you are sending emails. It is recommended that you should not save your SMTP password here. Instead, you must save your password in the wp-config.php file.

These configurations are required to connect to any SMTP server. Their values, however, may differ from one WordPress hosting company to the next. Here’s how to set up the WP Mail SMTP plugin with different hosting companies.

Method 2: Add the code in functions.php

In this method, you would require to enter the below code in the functions.php file of your WordPress site.

add_action( 'phpmailer_init', 'yoursite_phpmailer_init' );
function yoursite_phpmailer_init( PHPMailer $phpmailer ) {
    $phpmailer->Host = 'your.smtp.server.here';
    $phpmailer->Port = 25; // could be different
    $phpmailer->Username = 'your_username@example.com'; // if required
    $phpmailer->Password = 'yourpassword'; // if required
    $phpmailer->SMTPAuth = true; // if required
    // $phpmailer->SMTPSecure = 'ssl'; // enable if required, 'tls' is another possible value

    $phpmailer->IsSMTP();
}

Make the following changes as per your site in the above-mentioned code:

phpmailer_init - It is the hook
yoursite_phpmailer_init - It is the function name
$phpmailer->Host = 'your.smtp.server.here'; - Here Enter your SMTP Server
$phpmailer->Port = 25; - Here Enter your SMTP Port
$phpmailer->Username = 'your_username@example.com'; - Enter the SMTP username
$phpmailer->Password = 'yourpassword'; - Enter the SMTP password

Visit the Emails being sent with limited characters doc, which explains how to fix the emails not being fully sent to the users.

How can we help?