I’m encountering an issue with email delivery in OJS 3.3.4. When a user signs up, registration confirmation emails, as well as password change emails, are not being delivered. I found the following error message in logs:
stream_socket_enable_crypto(): Peer certificate CN=webserver.example.com' did not match expected CN=smtp.gmail.com’.
Both the Principal Contact and Support Contact email addresses are set to name@example.com.
Testing SMTP with online tools successfully delivers emails.
My site domain where OJS is hosted is my.example.com not example.com.
Despite successful SMTP testing with online tools, emails are not being delivered to users through OJS.
What could be causing this error?
I already tried that, but it’s still not working.
Do you think the issue could be because the site domain (my.example.com) and the email domain (example.com) are different? Any other ideas on what might be causing this?
Given that you’re using smtp.gmail.com to send emails, whether the site is installed on the main domain or a subdomain shouldn’t be an issue. Nonetheless, I suggest examining the PHP error codes for additional troubleshooting.
This is the error that I get when email isn’t sent Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate CN=webserver.example.com' did not match expected CN=smtp.gmail.com’.
are you referring to something else?
[email]
; Default method to send emails
; Available options: sendmail, smtp, log, phpmailer
default = smtp
; Path to the sendmail, -bs argument is for using SMTP protocol
sendmail_path = "/usr/sbin/sendmail -bs"
; Use SMTP for sending mail instead of mail()
smtp = On
; SMTP server settings
smtp_server = smtp.gmail.com
smtp_port = 587
; Enable SMTP authentication
; Supported smtp_auth: ssl, tls (see PHPMailer SMTPSecure)
smtp_auth = tls
smtp_username = testojsmail@gmail.com
smtp_password = App Password is a **16-digit passcode not an email password**
I have the same exact configuration with email 2FA and a 16-digit passcode, except my SMTP username is not a Gmail address; it is an example.com email address. I don’t know if this affects anything.
For temporary emails with less protection, when I sign up users with them, they receive emails from OJS, but Gmail users don’t. Also, the error logs only show PHP deprecated logs and not errors like before, even if the email isn’t received by the Gmail user. Is it because my.example.com isn’t verified or something? Does this have to do with SPF, DKIM, or other email authentication methods?
I recommend checking your SPF and DKIM settings to ensure Gmail users receive your emails. These methods help prevent emails from being marked as spam. Additionally, using your primary domain (name@example.com) is more reliable than using a subdomain (name@my.example.com).
For more information on Gmail SMTP settings and managing outbound gateway usage, you can refer to this link: Google Support.