Description of issue or problem I’m having: We have Wordpress on main domain <www.maindomain.com> and installed OJS on subdomain <subdomain.maindomain.com>. We have google workspace for our mail server, and want to configure OJS for gmail smtp. However, get_oauth_token.php results in ‘page not found’ instead of refresh token. the error log says:
PHP Notice: Undefined index: host in /home/username/public_html/wp-includes/canonical.php on line 687, 696, 699
in said canonical.php file these lines correspond to:
line 687: $original_host_low = strtolower( $original[‘host’] );
line 696: $redirect[‘host’] = $original[‘host’];
line 699: $compare_original = array( $original[‘host’], $original[‘path’] );
Steps I took leading up to the issue: We followed all the steps as recommended here Using Gmail with XOAUTH2 · PHPMailer/PHPMailer Wiki · GitHub, and as well as here Email . However, after sign-in window and allowing user consent screen, when display of refresh token is expected, we find a Wordpress style ‘page not found’.
What I tried to resolve the issue: Nothing yet. Maybe Wordpress and OJS are interfering but we have no idea how to sort this out.
Application Version - e.g., OJS 3.3.0-7:
Additional information, such as screenshots and error log messages if applicable:
Error logs:
[07-Mar-2022 15:25:37 UTC] PHP Notice: Undefined index: host in /home/username/public_html/wp-includes/canonical.php on line 687
[07-Mar-2022 15:25:37 UTC] PHP Notice: Undefined index: host in /home/username/public_html/wp-includes/canonical.php on line 696
[07-Mar-2022 15:25:37 UTC] PHP Notice: Undefined index: host in /home/username/public_html/wp-includes/canonical.php on line 699
As the error is being generated by canonical.php which is the default WP domain, maybe the get_oauth_token.php is not accessible or is being rewritten by the webserver?
Did you try to reach out for PHPMailer support? I believe they will know better what is going on.
Hi @gian !
here is the response from PHPMailer support:
It’s quite likely your app will refuse to serve a file directly from a vendor folder, which should not normally be inside the web root. This might manifest as serving your home page, so perhaps copy this script to the web root and adjust the callback URL to match.
I even copied get_oauth_token.php to OJS installation folder and modified the redirectUri in get_oauth_token.php and in google client ID authorised URIs. However the result was similar, it redirected to OJS homepage and not displayed the refresh token.
I tried and successfully fetched a refresh token in localhost environment and then used that in config.inc.php on live website. However, the result was still error sending email and following was recorded in error logs: (I tried to send email to reviewer in review round)
[10-Mar-2022 17:00:36 UTC] PHP Warning: Declaration of EmailReviewerForm::execute($submission) should be compatible with Form::execute(…$functionArgs) in /home/username/public_html/subdomain/lib/pkp/controllers/grid/users/reviewer/form/EmailReviewerForm.inc.php on line 18
[10-Mar-2022 17:00:52 UTC] PHP Warning: Declaration of EmailReviewerForm::execute($submission) should be compatible with Form::execute(…$functionArgs) in /home/username/public_html/subdomain/lib/pkp/controllers/grid/users/reviewer/form/EmailReviewerForm.inc.php on line 18
[10-Mar-2022 17:00:53 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
The email settings in my config.inc.php are as:
[email]
; Use SMTP for sending mail instead of mail()
smtp = On
; SMTP server settings
smtp_server = smtp.gmail.com
smtp_port = 465
; Enable SMTP authentication
; Supported smtp_auth: ssl, tls (see PHPMailer SMTPSecure)
smtp_auth = ssl
smtp_username = "my_email@my_domain_name.com"
smtp_password = "my_email_password"
;
; Supported smtp_authtype: RAM-MD5, LOGIN, PLAIN, XOAUTH2 (see PHPMailer AuthType)
; (Leave blank to try them in that order)
smtp_authtype = XOAUTH2
; The following are required for smtp_authtype = XOAUTH2 (e.g. GMail OAuth)
; (See https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2)
smtp_oauth_provider = Google
smtp_oauth_email = 'my_email@my_domain_name.com'
smtp_oauth_clientid = 'my_client_id'
smtp_oauth_clientsecret = 'my_client_secret'
smtp_oauth_refreshtoken = 'refresh token fetched under localhost environment'
; Enable suppressing verification of SMTP certificate in PHPMailer
; Note: this is not recommended per PHPMailer documentation
; smtp_suppress_cert_check = On
The PHPMailer support said:
Those declaration errors have nothing to do with PHPMailer?
I’m glad you a moving forward with this.
The warnings on the declaration should not be an issue, but the ‘SMTP connect() failed.’ message shows that the coinnection to smtp.gmail.com could not be done. By any chance can you get some better logging on the connection meesages.
Thanks @gian !
Though the things aren’t working as mentioned in phpmailer/ojs guides (such as on live web environment, get_oauth_token.php doesn’t result in refresh token), I somehow was able to sort this issue by:
Generated the refresh token in localhost environment as suggested by PHPMailer support (mentioned above).
Used smtp_port = 587 and smtp_auth = tls in config.inc.php file
This resolved the smtp connection issue.
However, now I am facing the next problem. if you, or someone else, can help me?