Using SMTP for sending emails in OJS

If we used SMTP instead of mail(), would the emails sent via OJS appear in sent-folder of our mailing programme?


No, just using SMTP for delivery wouldn’t copy the message to the sender’s email account.

To archive a copy of the messages in the sender’s email account you would need to change the code to BCC the sender for each message sent.

1 Like

I changed settings in file to try out SMTP for sending emails via OJS.
And this is not working - now no emails are delivered by OJS. I’d like to know what could be a problem.
I put server name, port, user, password, smtp_auth = PLAIN and uncommented these rows.
Our server uses SSL/TLS. Can you help me?


1 Like

This will be very dependent on your SMTP provider. You may be able to find more details on the error in your webserver’s error log, but you may also need to check with the provider, as they would be the ones with access to the SMTP logs. One log or the other will describe the problem.

You can see an example SSL configuration for gmail here:


In th link provided here, do we keep the Quotation marks " "

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

; SMTP server settings
smtp_server = “ssl://”
smtp_port = 465

; Enable SMTP authentication
smtp_auth = PLAIN
smtp_username = “
smtp_password = “password”

1 Like

The quotation marks are optional.

We set up this with our website and has been working, but since last week it stopped to send email. We can not figure out why. The account used for this is working and this is no issue. Any suggestion please?

The log file says

AH01071: Got error ‘PHP message: ojs2 has produced an error\n Message: WARNING: fsockopen(): unable to connect to ssl:// (Connection timed out)\n In file: *****/\n At line: 165\n Stacktrace: \n Server info:\n OS: Linux\n PHP Version: 5.6.22-0+deb8u1\n Apache Version: N/A\n DB Driver: mysql\n DB server version: 10.0.25-MariaDB-0+deb8u1\n’, referer:

The error message seems to indicate that your server is unable to connect to the server over port 465.

If you have shell access and nc installed, you can try testing the connection:
nc -zv 465
This should respond:

Connection to 465 port [tcp/urd] succeeded!

The most likely cause of not being able to connect suddenly is a firewall change between your sever and the destination server.

1 Like

ojs2 has produced an error Message: WARNING: fsockopen() [function.fsockopen]: unable to connect to ssl:// (Network is unreachable) In file: /home/insajour/public_html/insaj/lib/pkp/classes/mail/ At line: 165 Stacktrace: Server info: OS: Linux PHP Version: 5.3.29 Apache Version: N/A DB Driver: mysql DB server version: 5.5.48-cll

Anybody give me solution of this problem?

Did you try the netcat (nc) command above via the shell? It sounds as if the problem isn’t in OJS, but is at your system or network level. Specifically, the message states that your server couldn’t connect to gmail because the request wasn’t network routable. The nc command would confirm whether you have network connectivity to gmail.

Try forwarding this error message to your system administrator or hosting provider for additional debugging.

I don’t know how to use netcat (nc) command above via the shell. Bcoz i have no idea of shell. Please tell how to use shell?

ojs2 has produced an error Message: WARNING: fsockopen() [function.fsockopen]: unable to connect to ssl:// (Connection timed out) In file: /home/insajour/public_html/insaj/lib/pkp/classes/mail/ At line: 165 Stacktrace: Server info: OS: Linux PHP Version: 5.3.29 Apache Version: N/A DB Driver: mysql DB server version: 5.5.48-cll

How to resolve this problem?

If you are on managed hosting and do not have access to SSH for shell commands, you will need to check with your system administrator or hosting provider to see why your connections are failing.

Tell them you are “unable to connect to on port 465 because the connection times out.”


I’m using window 8 (64 bit). So what any problem with window 8 (64bit) for
can’t email with smtp?

Please give me replay ASAP.


You can test whether Windows has access to the gmail smtp on port 465 with this tutorial:

If Windows does not have access, OJS cannot get access and you will need to check with your system or network administrator to find out why this connection is blocked.

If Windows does have access, but OJS does not, then the next step will be to look at your webserver and PHP configuration.

We got issue with this SMTP again, Any idea with this generated error is trying to tell us when we send email to author please? It semas that the email is sent but as clicked a bank page with text (404 Not Found) is shown.

AH01071: Got error 'PHP message: ojs2: 404 Not Found\n', referer:

We are using google Apps and we have done the setup based on the instruction here

The command running give us

nc -zv 587
DNS fwd/rev mismatch: != [] 587 (submission) open

The connection to gmail is seems to be successful with a warning about the forward and reverse DNS not matching. I suspect your problem lies in the 404 message.

What is the URL which actually generates the 404 error? Given the referral URL, it may be something like:[]= ... &articleId=96.
Also, what is your exact workflow to replicate this error?

Ah! I see, we have shorten the URL and this is generated URL

That …/aro/… should not be there. it should read which I tried and it works

So the base url does not work in this case.

From submission page I click to send email to author and gives me correct URL[]=Hamid%20Turki%20Maliki%20<>&subject=&articleId=91

which I send the email, which email is sent successfully, the return page land in 404 Not found, which is caused by that extra /aro/ which should not be there. I refer to this discussion which we had before

Hi @ctgraham,

Could you explain what this option means?

I am using own mail server. Don’t know how, but I have managed to make running a bunch of needed for this programs.
Our OJS 3.0.2 has been configured to send mails directly through SMTP.
All works fine, even all emails not end up in spam folders of recipients.
But I like to get more info about this line.

The smtp_auth option determines how the username/password authentication is transmitted to the server. “PLAIN” means the password is sent as-is, in plaintext. Some SMTP servers will support or require other methods, like encrypting or hashing the password before sending it. Available options are listed in the preceding line:

; Supported mechanisms: PLAIN, LOGIN, CRAM-MD5, and DIGEST-MD5

For security, you would want to use the plaintext transmission of a password only over a secure channel, such as SSL or TLS.