Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending activation emails through GMail #1

Closed
enterv0id opened this issue Feb 23, 2021 · 7 comments
Closed

Sending activation emails through GMail #1

enterv0id opened this issue Feb 23, 2021 · 7 comments

Comments

@enterv0id
Copy link

enterv0id commented Feb 23, 2021

Hi,

Thanks for sharing this awesome work, I love it! I'm trying to use the PHPMailer function to send out activation emails through gmail account:
const EMAIL_HOST = 'smtp.gmail.com';
const SMTP_PORT = '587';

I've already enabled less secure apps and IMAP access in Gmail settings, but it throws this fatal error right after registration:

2021/02/23 22:55:53 [error] 36592#36592: *721 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Class 'PHPMailer\PHPMailer\Exception' not found in /var/www/html/test/PHPMailer/PHPMailer.php:2035
Stack trace:
#0 /var/www/html/test/PHPMailer/PHPMailer.php(1855): PHPMailer\PHPMailer\PHPMailer->smtpConnect()
#1 /var/www/html/test/PHPMailer/PHPMailer.php(1598): PHPMailer\PHPMailer\PHPMailer->smtpSend()
#2 /var/www/html/test/PHPMailer/PHPMailer.php(1434): PHPMailer\PHPMailer\PHPMailer->postSend()
#3 /var/www/html/test/class.php(182): PHPMailer\PHPMailer\PHPMailer->send()
#4 /var/www/html/test/class.php(95): doRegisterAttempt->sendVerifyEmail()
#5 /var/www/html/test/register/register_handle.php(12): doRegisterAttempt->attemptRegister()
#6 {main}
  thrown in /var/www/html/test/PHPMailer/PHPMailer.php on line 2035" while reading response header from upstream, client: 162.158.92.122, server: *******, request: "POST /test/register/register_handle.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "*******", referrer: "https://*******/test/register/"

I'm not sure how to resolve the Exception issue. Should I use compose for PHPMailer?
Thanks in advance

@cp6
Copy link
Owner

cp6 commented Feb 23, 2021

It would be best to use composer, I didn't initially do it this way because I wanted it to be simple.

However, it looks like the error is from the missing Exception.php file.

Link for non composer solution?

@enterv0id
Copy link
Author

It works perfectly using composer require function. Thank you!

@enterv0id enterv0id reopened this Feb 24, 2021
@enterv0id
Copy link
Author

My only issue now the activation link. When I click on it, it drops this error in nginx log:

2021/02/24 10:49:03 [error] 46388#46388: *394 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to protected method doRegisterAttempt::verifyAccount() from context '' in /var/www/html/dashboard/activate.php:5
Stack trace:
#0 {main}
  thrown in /var/www/html/dashboard/activate.php on line 5" while reading response header from upstream, client: 162.158.88.116, server: ********, request: "GET /dashboard/activate.php?key=552fe0ce102b88bdc4ed6f75 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "*******"

@cp6
Copy link
Owner

cp6 commented Feb 24, 2021

commit 39805104c33a87abe6c0f811aad3a9f226fb9fda should fix this

@enterv0id
Copy link
Author

changing to public returns Error: Call to a member function outputString() on bool in /var/www/html/dashboard/activate.php:6

line 6 in activate.php
($verify) ? $verify->outputString("Account activated") : $verify->outputString("Key is invalid");

Now it removes the key for the registered uid from activate_keys in MySQL before returning the error when clicking activation link and activates the registration, only the return message function not working

@cp6
Copy link
Owner

cp6 commented Feb 25, 2021

My mistake, i just had the wrong variable assigned 0c706c53ca8b50209fb0be26e493ed6457010957.

@enterv0id
Copy link
Author

Everything's perfect now, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants