-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix: validate SMTP credentials using SMTPAuth #9668
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Controller
participant PHPMailer
Client->>API_Controller: PATCH /v1/projects/:projectId/smtp (with SMTP settings)
API_Controller->>PHPMailer: Initialize and configure SMTP
API_Controller->>PHPMailer: Set SMTPAuth = (username && password ? true : false)
API_Controller->>PHPMailer: Attempt SMTP connection
PHPMailer-->>API_Controller: Success or failure
API_Controller-->>Client: Respond with result
Assessment against linked issues
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please also add test cases?
@@ -1683,6 +1683,7 @@ | |||
if ($enabled) { | |||
$mail = new PHPMailer(true); | |||
$mail->isSMTP(); | |||
$mail->SMTPAuth = (!empty($username) && !empty($password)) ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to
$mail->SMTPAuth = (!empty($username) && !empty($password)) ? true : false; | |
$mail->SMTPAuth = (!empty($username) && !empty($password)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this
I just added unit test to verify SMTP authentication with invalid credentials. |
What does this PR do?
This PR fixes issue #9067 by enabling SMTP authentication in the projects.php controller.
Without setting $mail->SMTPAuth, PHPMailer does not validate the provided username and password.
This fix ensures that invalid SMTP credentials will be correctly rejected when updating a project's SMTP settings.
Test Plan
$mail->SMTPAuth = (!empty($username) && !empty($password)) ? true : false;
to the validation block.Related PRs and Issues
Checklist
Summary by CodeRabbit
Chores
Bug Fixes