swcreates
swcreates

Reputation: 21

UserFrosting (0.3.x) SMTP email error

[UserFrosting 0.3.x]

I just set up UserFrosting, and everything looks to be working, except one tiny thing...

When a user goes to register, there's an error "Fatal error attempting mail, contact your server administrator"

In the config-userfrosting.php, the smtp section is filled out as:

        'mail' => 'smtp',
        'smtp'  => [
            'host' => 'smtp.scottywcreates.com',
            'port' => 465,
            'auth' => true,
            'secure' => 'ssl',
            'user' => '[email protected]',
            'pass' => '------'
        ],

(password blacked out)

Why am I getting this error?

Upvotes: 1

Views: 343

Answers (1)

alexw
alexw

Reputation: 8688

The message that the user sees is just a generic error message, indicating that there was some problem with the mail server. It purposefully avoids giving specific details, that you may not want to disclose to the general public.

To find out the specific error condition, you will need to check your PHP error log. Please check with your particular server configuration to find the location of the PHP error log.

UserFrosting uses PHPMailer to send mail. By default, PHPMailer doesn't output any detailed SMTP error information, so you will likely see a generic exception message in the error log as well (for example, "SMTP Error: Could not authenticate.")

To obtain more detailed error information, you can hack userfrosting/models/Notify/Notification.php and change PHPMailer's default settings. Add the following configuration values to the other SMTP configuration values:

$mail->Debugoutput = 'error_log';
$mail->SMTPDebug = 4;

This will tell PHPMailer to dump very detailed connection and error information to the PHP error log. Once you do this, you should be able to see why exactly your SMTP server is rejecting UserFrosting's emails.

Common reasons that SMTP fails:

  • Many SMTP servers require that the authenticated account (in your case, [email protected]) matches the From address in the actual email. By default, account verification emails are sent from the "Account Management Email" address set under Configuration -> Site Settings. So, you might try checking that it matches the address you use to authenticate in config-userfrosting.php.
  • Using the wrong port or authentication method. See the Email Troubleshooting wiki.

Upvotes: 1

Related Questions