Subscription do-not-reply email causing issues with some mail servers connecting via SMTP
Overview
We used integration via Contact Form 7 integration to connect Contact Form 7 in order to send data directly to CiviCRM. This works when server is connected to mail() but not via SMTP for some servers.
This issue is only present when you use Mailing Event: Subscribe to mailing list as Action in form processor.
The client uses cPanel, which by default has setup to decline all emails that do not exist (ex do-not-reply@domain.com). They do not use catchall. The issue itself is CiviCRM related, not FormProcessor.
When its set to SMTP, it tries to send email stimulating address do-not-reply@domain.com Since it doesn't exist and SMTP is directly connected to only one email that wont work, as it tries to use that address for Subscribing process. When you send via mail() function you get email from proper email, but since server stimulates it, it doesn't cause a bug in that state.
Reproduction steps
- Connect via SMTP to some cPanel SMTP or similar host that doesn't have catchall/VERP/do-not-reply@domain.com address present
- Click on Administration -> Automation -> Form processor
- Create Form processor that only has email for value
- Add XCM contact matcher to match contact
- Add type Mailing Event: Subscribe to mailing list
- Save and Close -> Try out out
Current behaviour
When you try to fill out Contact Form 7 and it has SMTP connected, data is submitted but submission itself is not sent to the user. When you use Try Out option for Form Processor you get error from the system: Unable to send email. Please report this message to the site administrator In logs you can find this:
[error] Mailing error: Failed to add recipient: user@website.org [SMTP: Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM >> Global Settings >> Outbound Email (SMTP). (code: 550, response: Verification failed for...
SMTP and bounce processing is functioning perfectly for newsletter.
Expected behaviour
It should by default use SMTP address not ask for do-not-reply@domain.com address as it sends even via SMTP with our hotfix. This causes issues for some SMTP connections, from some hosts. In this case from cPanel which does not have catchall setup or do-not-reply@domain.com address.
Current hotfix for client's needs
We made an edit in file civicrm/CRM/Mailing/Event/BAO/Subscribe.php on line 208 on master ('returnPath' => CRM_Core_BAO_Domain::getNoReplyEmailAddress()) to force to use same address as SMTP one and that works when subscription is received.
'returnPath' => 'smtp@domain.com',//CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
Environment information
- Browser: Firefox 105.0/Chrome 105.0.5195.127
- CiviCRM: 5.47.4
- PHP: Php-7.4
- CMS: Drupal-7.91
- Database: mysql-8.0.30-0ubuntu0.20.04.2
- Web Server: apache2-2.4.41
Comments
Chat link of discussion: https://chat.civicrm.org/civicrm/pl/1sqat1uwo3befca91akhmdzsre
Creating do-not-reply@domain.com address is also another fix, but its not noted anywhere but it should exist, either fixing this for global use or adding in CiviCRM to report that do-not-reply@domain.com doesn't exists should suffice.