SMTP e-mail error

  • Application Version - OJS 3.1.2.4

  • Description of issue
    Every time the system should send notification e-mail to the authors a message appears in red in the corner of the screen stating that there was a problem and the e-mail cannot be sent (this occurs when trying to inform that the article was accepted or rejected, any direct message to the authorwas chosen).

*Screenshot
problema e-mail - 4-jan - 11h20

Hi @andersonvm

I want to share a situation I had experienced a short time ago. Although I have entered correct username, password and all the smtp settings such as smtp port and SMTP authentication mechanism (ssl, or tls), I had the same error. Then I realized that, SSL certificate was not accepted by the Mail Transfer Agent (Postfix) because the SSL certificate didn’t include the journal domain. Since I have the root privileges, I added the journal domain to server domain ssl certificate, installed to Postfix mail server and the issue was resolved.

So, if the smtp settings in confic.inc.php are correct, you have probably a server related problem and this might be a starting point to investigate the problem.
Best regards,

Hi, @drugurkocak .

Thank you in advance for your contribution. However, our SSL certificate is valid as you can see, take a look: SSL Checker
I think the problem is being caused by something else.

Best regards.

Hello, @andersonvm !
The same problem in OJS 3.1.2.
I attempted use both university server and smtp.gmail.com. 465 and 587 ports in config.inc.php.
Additional information is so: after use smtp.gmail.com on 465 I became an alarm email from Google with the heading “Suspicious sign in prevented”. I turned on “Allow less secure apps:” in Google account settings. Now I receive Google security -messages no more, but OJS-mail still doesn’t work ))

Hi @andersonvm
You are right, as in my case, there is no problem with the validity of your SSL certificate. When I talk about a configuration error, I mean the server might need to be configured to use that certificate by the mail server (not web server). That is only an option and depends on your server environment.
For example, do you use DNSSEC and DKIM, and sign outgoing mails with a key?
Regards,

Hi, @drugurkocak
We are running the OJS services in a Docker container. There is currently no specific email configuration in the container, since the smtp server is external. There is no other occurrence of email problems, only in the OJS system.
Regards.

@asmecher can you help me?

Hi @Spaik

Sending and receiving email via an email client (such as Apple Mail or Microsoft Outlook) is not the same thing with using Google SMTP server freely.
If it would be so, there would be no Yahoo Mail Business or Google Mail Business, isn’t it?
In order to use free Gmail SMTP server, you might need to create a web application, generate api key etc…
Although related to Worpress CMS, that page has a detailed tutorial on how to use Gmail smtp server. I think we need to follow the same procedure in order to use that service. Hope it helps you:

Regards,

Hi, @drugurkocak ! Thank you for answer.

But what can you say about this forum thread and other samples on this forum :
OJS 3xx Using SMTP don’t send email__Help___ ?

Hi @Spaik
I have read the topic and It is a story of unsuccess. But since one user has reported that he had succeeded, I will install a new ojs and try with my own Gmail account. I hope I get a successful result and share here.
Regards,

Hi @Spaik

I installed and configured a new ojs 3.3 on a domain

When I used phpmail (smtp off), the journal can send emails. When I configured OJS config to use local smtp server (Postfix server that runs as hostname), I was unable to send email untill I add journal domain to server’s SSL certificate and copy the new certificate to Postfix.

When I configured OJS config to use gmail smtp with my personel gmail account, I got a “Sign-in attempt was blocked” at first attempt. When I checked “it was me” option in Google security, and tried again, I got “Less secure application attempted to login” alert. Although I enabled “Less secure app blocked”, I can’t still send any mail using Google smtp.

When I tried to use local mail server using journals domain, OJS can send email, but immediately rejected by Gmail and Hotmail and iCloud mail. The mail didn’t reach even the spam folder.
The iCloud mail service clearly states that it won’t accept any email having no valid DMARC policy and signed by DKIM.

When I tried to send the email after adding the journal’s domain to “Domains to sign for” DKIM, and configured DNS record, DMARC record, DMARC policy for emails that fail SPF or DKIM, SPF record, I could be able to send email using local smtp server. The email was accepted by the recipient servers this time.

So, in order to send mails using a smtp server, we might need to do more. And I believe that in this situation, the coin has two faces. Fighting spam on the one hand, and the email business sector on the other. And nothing is free in the email world as it was 20 years ago because of spam flood.
Regards,

1 Like

Hi, @drugurkocak !
Thank you very much for your job!
You put the information on the shelves like in a textbook
I believe that this will be useful to many forum participants and not only to them.
Best regards,

Thank you very much @drugurkocak.
I corrected the error. In fact, the Docker process was having a problem. The Docker process was without any external communication. To be honest, I don’t know why.
We will install the OJS in a dedicated serve for this purpose.

Hi @andersonvm
I am glad to hear that you have solved the problem. Do you use Gmail smtp server as the external server, or another business mail service, or your own mail server? If you use Gmail or some other smtp server, how did you configured it and succeeded?
Best regards,

Hi @drugurkocak
Here at the university we have a dedicated SMTP server, but we use the Gmail service (GSuit).
For now, we are using it in a Docker container, but we are going to migrate it to a dedicated server that will be used only for this purpose.

Below, you can see the configuration used

[email]

; Use SMTP for sending mail instead of mail()
smtp = On

; SMTP server settings
smtp_server = smtp.gmail.com
smtp_port = 587

By the way, how do you use your configuration? I mean about your setup. Do you use a dedicated server, Docker container, shared server

Hi @andersonvm ,
Thank you for your kind reply. It is a commercial xcloud server (I think like a Vmware virtual machine). I installed Centos 7 from scratch. Then Virtualmin, Apache, Php, MariaDb, Postfix, Dovecot imap server etc.
The SSL certificate is requested from Let’s Encrypt authority and used on all services.
I use it solely for OJS journals, and but can run anything.

I follow Postmaster emails and the emails generally reach the recipients. They send dmarc-support reports regularly. For ex;

 <count>33</count>
       <policy_evaluated>
         <disposition>none</disposition>
         <dkim>**pass**</dkim>
         <spf>**pass**</spf>
       </policy_evaluated>
     </row>
     <identifiers>
       <header_from>akademisyen.net</header_from>
     </identifiers>
     <auth_results>
       <dkim>
         <domain>akademisyen.net</domain>
         <result>**pass**</result>
         <selector>academician</selector>
       </dkim>
       <spf>
         <domain>akademisyen.net</domain>
         <result>**pass**</result>
       </spf>

With your port settings, I get these errors in error log :slight_smile:

[11-Feb-2021 22:13:27 Europe/Istanbul] Connection: opening to ssl://smtp.gmail.com:587, timeout=300, options=array()
[11-Feb-2021 22:13:27 Europe/Istanbul] Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol [/home/adlitip/public_html/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[11-Feb-2021 22:13:27 Europe/Istanbul] Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/home/adlitip/public_html/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[11-Feb-2021 22:13:27 Europe/Istanbul] Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:587 (Unknown error) [/home/adlitip/public_html/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[11-Feb-2021 22:13:27 Europe/Istanbul] SMTP ERROR: Failed to connect to server: (0)
[11-Feb-2021 22:13:27 Europe/Istanbul] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub


When I set protocol to tls, or change the port number, the following error lines are logged.

[11-Feb-2021 22:19:48 Europe/Istanbul] Connection: opening to smtp.gmail.com:587, timeout=300, options=array()
[11-Feb-2021 22:19:48 Europe/Istanbul] Connection: opened
[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 220 smtp.gmail.com ESMTP m5sm8890843wmc.25 - gsmtp

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: EHLO www.adlitip.net

[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 250-smtp.gmail.com at your service, [37.148.209.149]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: STARTTLS

[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 220 2.0.0 Ready to start TLS

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: EHLO www.adlitip.net

[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 250-smtp.gmail.com at your service, [37.148.209.149]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: AUTH LOGIN

[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 334 VXNlcm5hbWU6

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: [credentials hidden]
[11-Feb-2021 22:19:48 Europe/Istanbul] SERVER → CLIENT: 334 UGFzc3dvcmQ6

[11-Feb-2021 22:19:48 Europe/Istanbul] CLIENT → SERVER: [credentials hidden]
[11-Feb-2021 22:19:49 Europe/Istanbul] SERVER → CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs
534-5.7.14 b0O-iHug57Uyf9cRZj4pESBXp_AwoCnxozM8KH-K7wdxiVMVplFK6OeLh2K5BkSngw7CG
534-5.7.14 fxexhw2bFtjqKNkGpIj9ttQxtgpP7xOZx0f31GUwpiI3zu-cJ-vsB403gw13eCbF>
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 m5sm8890843wmc.25 - gsmtp

[11-Feb-2021 22:19:49 Europe/Istanbul] SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs
534-5.7.14 b0O-iHug57Uyf9cRZj4pESBXp_AwoCnxozM8KH-K7wdxiVMVplFK6OeLh2K5BkSngw7CG
534-5.7.14 fxexhw2bFtjqKNkGpIj9ttQxtgpP7xOZx0f31GUwpiI3zu-cJ-vsB403gw13eCbF>
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 m5sm8890843wmc.25 - gsmtp

[11-Feb-2021 22:19:49 Europe/Istanbul] SMTP Error: Could not authenticate.
[11-Feb-2021 22:19:49 Europe/Istanbul] CLIENT → SERVER: QUIT

[11-Feb-2021 22:19:49 Europe/Istanbul] SERVER → CLIENT: 221 2.0.0 closing connection m5sm8890843wmc.25 - gsmtp

[11-Feb-2021 22:19:49 Europe/Istanbul] Connection: closed
[11-Feb-2021 22:19:49 Europe/Istanbul] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[11-Feb-2021 22:19:49 Europe/Istanbul] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

Although I’m not sure, I think the following lines support my opinion: “SMTP Error: Could not authenticate.”
Long story short, big brothers are happy when we use their services, and pay them.
Regards,

@drugurkocak
Thank you for sharing your knowledge with me.
I forgot. We also use the SSL certificate.
I have a question. Could you tell me where I can research about the DMARC configuration? What do I need to configure it on my server?

Hi @andersonvm
This depends on the software you use for Server management such as Cpanel, Virtualmin etc. Since it is free, I installed and use Webmin/Virtualmin.
Some software packages should have been installed in order to use these features. Since I have only one server, I installed all on the same server. Email signing has several components.
I remember that I have installed BIND DNS, DNSSEC, OpenDKIM. Then I configured them step by step.
In virtualmin, you may configure DKIM record, Virtualmin → Email Settings → DomainKeys Identified mail after setting up dmarc records in DNS
Webmin → Servers → BIND → DNSSEC Verification → DNSSEC Enabled
DMARC record is added among DNS records by Virtualmin automatically.
DKIM private key and Public keys are generated through Virtualmin → Server Configuration → Domainkey Options.
You should also visit Virtualmin → Server Configuration → DNS options in order to enable SPF record, DMARC record and DNSSEC signature for each domain.
I also removed the server ip from spam lists because it has been used for spam previously and blocked by several. servers.
Regards,

Hi, @drugurkocak!
There is an interesting thing: now I become an error message only while submitting a new article. All other messages are receiveng by the autor correctly. I use phpMailer.php.
Maybe can you suggest an answer :?)

Hi @Spaik
If you could share more details about the error, me or other contributors will be pleased to help you.

I tried a lot on this, and learned that use of PhP without a valid SMTP server remained in the old days.

Let’s look what PHPMailer is, and what it is not. As far as I know about PHPMailer, it is a php function to send mails. PhP itself does not send any mail, but should use other mail transport software.

For ex;

Using PHP mail() function invokes a Sendmail program, usually configured by the system administrator, that allows you to send emails.

PHPMailer is the classic email sending library for PHP. It supports several ways of sending email messages such as mail(), Sendmail, qmail, and direct dispatch to SMTP servers. In addition, it provides a list of advanced features:

  • SMTP authentication
  • secure/MIME encryption
  • support of TLS and SSL protocols
  • HTML content along with plain text
  • multiple fs, string, and binary attachments
  • embedded images support

In most cases, it’s an alternative to PHP’s mail() function, but there are many other cases where the mail() function is simply not flexible enough to achieve what you need.

First of all, PHPMailer provides an object-oriented interface, whereas mail() is not object oriented. PHP developers generally hate to create $headers strings while sending emails using the mail() function because they require a lot of escaping. PHPMailer makes this a breeze. Developers also need to write dirty code (escaping characters, encoding and formatting) to send attachments and HTML based emails when using the mail() function, whereas PHPMailer makes this painless.

Also, the mail() function requires a local mail server to send out emails, which is not always trivial to set up. PHPMailer can use a non-local mail server (SMTP) if you have authentication.

So, if you have not configured OJS config.inc.php to use SMTP, than it needs to use some other MTA by means of PhPMailer. The error that you get, and error messages depend on that software.

We can start digging through the problem by looking into php-error log in your OJS hosting account. Besides this, we should also carefully examine each line of the mail headers that were successfully sent to other recipients.

If we talk about Gmail, iCloud or Hotmail, there is a 100% chance that emails without DMARC signature will go to the spam folder. This may even be a success because iCloud rejects emails without a dkim signature.

An example for a successful mail header;

Authentication-Results: spf=pass (sender IP is 37.148.209.149)
smtp.mailfrom=akademisyen.net; hotmail.com; dkim=pass (signature was
verified) header.d=akademisyen.net;hotmail.com; dmarc=pass action=none
header.from=akademisyen.net;compauth=pass reason=100
Received-SPF: Pass (protection.outlook.com: domain of akademisyen.net
designates 37.148.209.149 as permitted sender)

If these spf record, dkim signature or dmarc sign couldn’t pass necessary checks, the. mail is again treated as spam, either moved to Spam folder (Quarantina) or rejected depending on recipient server’s policy.

Do you get the pink coloured error message saying that There was an error while sending the email, or get no error?
Regards,

Screen Shot 2021-03-02 at 17.40.31