salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.44k stars 2.07k forks source link

BUG: Incorrect From Email Address returned by OutboundEmailAccounts module if SMTPUser is valid email #10317

Open MatthewHana opened 8 months ago

MatthewHana commented 8 months ago

Issue

There is a bug in the getFromAddress function of the OutboundEmailAccounts module.

The function returns the SMTP User if it is a valid email address and the From address is not empty. It also returns the SMTP User if it is not a valid email address if the From address actually is empty.

Expected Behavior

If the From email is empty, then the function should return the SMTP User only if it is a valid email address. Otherwise it should return the From address that was set.

Actual Behavior

The SMTP User is returned if it is a valid email address and a From address is set. If no From address is set, then the SMTP User will be returned even if it is not a valid email address. (see attached screenshot).

Possible Fix

An || operator was used instead of an && operator (as is the case in the getReplyToAddress function).

Line: 307
File: modules/OutboundEmailAccounts/OutboundEmailAccounts.php

if (empty($fromAddress) || isValidEmailAddress($this->mail_smtpuser, '', false, '')) {

Steps to Reproduce

  1. Create a new Outbound Email Account with the following details: From Address: from@example.local (valid email address) SMTP Username: smtp@example.local (valid email address)
  2. Compose a new Email from the Email module and select the From dropdown (smtp@example.local is used)
  3. Edit the same Outbound Email Account and set From Address to blank and change SMTP User to smtp.example.local (invalid email address)
  4. Compose a new Email from the Email module and select the From dropdown (smtp.example.local is used)

Context

Cannot use the correct From address in an outbound email account. Medium priority as it could impact on email deliverability.

Your Environment

Attachments

SuiteCRM Email Bug 1 SuiteCRM Email Bug 2

MatthewHana commented 8 months ago

Happy to fix and make a simple PR if confirmed to be a bug.