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?

AS

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 cofig.inc.php 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?

AS

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:
https://pkp.sfu.ca/wiki/index.php?title=Using_gmail_SMTP

2 Likes

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.gmail.com”
smtp_port = 465

; Enable SMTP authentication
smtp_auth = PLAIN
smtp_username = “user@gmail.com”
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://smtp.gmail.com:465 (Connection timed out)\n In file: *****/aro.koyauniversity.org/lib/pkp/classes/mail/SMTPMailer.inc.php\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: http://aro.koyauniversity.org/editor/assignEditor?articleId=93&editorId=3

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

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

Connection to smtp.gmail.com 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://smtp.gmail.com:465 (Network is unreachable) In file: /home/insajour/public_html/insaj/lib/pkp/classes/mail/SMTPMailer.inc.php 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://smtp.gmail.com:465 (Connection timed out) In file: /home/insajour/public_html/insaj/lib/pkp/classes/mail/SMTPMailer.inc.php 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 smtp.gmail.com on port 465 because the connection times out.”

Hello,

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.

Thanks,

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: http://aro.koyauniversity.org/user/email?redirectUrl=http%3A%2F%2Faro.koyauniversity.org%2Faro%2Feditor%2Fsubmission%2F96&to%5B%5D=Suad%20M.%20Alfatlawi%20%3Csuad.alfatlawi%40gmail.com%3E&subject=AN%20EVALUATION%20OF%20THE%20ENVIRONMENTAL%20IMPACT%20ASSESSMENT%20PROCESS%20IN%20IRAQ&articleId=96

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

https://support.google.com/a/answer/2956491?hl=en

The command running give us

nc -zv smtp-relay.gmail.com 587
DNS fwd/rev mismatch: gmail-smtp-relay.l.google.com != wa-in-f28.1e100.net
gmail-smtp-relay.l.google.com [64.233.184.28] 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:
http://aro.koyauniversity.org/aro/editor/submission/96&to[]= ... &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

http://aro.koyauniversity.org/aro/editor/submission/91

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

http://aro.koyauniversity.org/editor/submission/91

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

http://aro.koyauniversity.org/user/email?redirectUrl=http%3A%2F%2Faro.koyauniversity.org%2Faro%2Feditor%2Fsubmission%2F91&to[]=Hamid%20Turki%20Maliki%20<hamid.haykal%40gmail.com>&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.

2 Likes