Original summary: "It is observed that when invalid address is provided, smtp module does add watchdog but does not mentioned the invalid email address in watchdog entry."
Optional summary: "In cases with multiple addresses, the code will add a space in front of the second and subsequent addresses in the comma delimited string, causing the later portion of the SMTP module code to interpret this as an invalid address."

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dineshw created an issue. See original summary.

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

The problem here is that the address value being used was blank, for some reason. In case the summary on the dbdog list page is being truncated, can you please paste in the details from the full watchdog message?

TuWebO’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
578 bytes

Hello,
Just watching this module and I realized that maybe the smtp_send_queue_runner function has wrong key values for one parameter of the watchdog function.

I just created a patch for it, maybe it is what is causing this issue.

TuWebO’s picture

Hello,
I added the !error_message also as 3rd key and updated the patch, don't know if it is correct so reviews will be very welcome.

nidhi.badani’s picture

Will be testing and sharing the results soon.

nidhi.badani’s picture

Assigned: Unassigned » nidhi.badani
GeduR’s picture

I'm not sure if patch solves this issue as this code is for legacy reasons, but it fixes a php coding error. '@form" without quotes are considered defined vars despite the @ which hides the error

wundo’s picture

Status: Needs review » Reviewed & tested by the community
wundo’s picture

wundo’s picture

Issue tags: -watchdog

  • wundo committed 78fbb35 on 7.x-1.x authored by TuWebO
    Issue #2681999 by TuWebO, dineshw, wundo, nidhi.badani: SMTP Error:...
wundo’s picture

Status: Reviewed & tested by the community » Fixed

  • wundo committed 78fbb35 on 7.x-2.x authored by TuWebO
    Issue #2681999 by TuWebO, dineshw, wundo, nidhi.badani: SMTP Error:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

catalinvlad’s picture

I've also encountered this issue while sending some emails using webform module to multiple addresses. The problem is that webform is building a string with a space after the comma so when the string is exploded, the space makes the email invalid.

So calling the function $this->_get_components(' abc@yahoo.com') will return the array ['input' => ' abc@yahoo.com', 'name' => '', 'email' => ''] - email is empty and it's used in the next line $mailer->AddAddress($to_comp['email'], $to_comp['name'])

I've managed to fix the issue by trimming the email before is validated in the _get_components function.

  protected function _get_components($input) {
    $components = array(
      'input' => $input,
      'name' => '',
      'email' => '',
    );

    // If the input is a valid email address in its entirety, then there is
    // nothing to do, just return that.
    $input = trim($input);
    if (valid_email_address($input)) {
      $components['email'] = $input;
      return $components;
    }

    // Check if $input has one of the following formats, extract what we can:
    //  some name <address@example.com>
    //  "another name" <address@example.com>
    //  <address@example.com>
    if (preg_match('/^"?([^"\t\n]*)"?\s*<([^>\t\n]*)>$/', $input, $matches)) {
      $components['name'] = trim($matches[1]);
      $components['email'] = trim($matches[2]);
    }

    return $components;
  }
}
jeromewiley’s picture

Issue summary: View changes

Used the suggestion from @cvlad_tremend in comment 15 and it began sending to all multiple addresses again (initially was throwing SMTP errors).
Rolling patch.

jeromewiley’s picture

Find patch attached. Per Richard Eriksson (Acquia), it appears this was fixed in the SMTP module, but a subsequent security update came through and the change was reverted. Began seeing email failures on December 27, the day after the SMTP 7.x-1.6 security patch came out. First email in array will deliver fine (forms that only send to one email are thus unaffected.) Second and subsequent email addresses are all interpreted as invalid because of a leading space.

joelstein’s picture

@jeromewiley, since this issue is closed and can only be re-opened by maintainers, would you kindly report this in a new issue so we can track it there?

joelstein’s picture

Nevermind, I posted a follow-up issue at #2856373: Problem with multiple email addresses.

ogursoy’s picture

I can confirm #15 is the issue for those using web forms & rules to send some custom emails. For emails, changing token [data:email-value] to [data:email-value-raw] fixed my problem.

dadderley’s picture

The issue as described in comment 15 seems to have reappeared.

Drupal core 7.67
SMTP Authentication Support 7.x-1.7
Webform 7.x-4.19

Webforms that send email to multiple addresses generate this error.
The mail does not get sent.

When I removed one of the email addresses so that the form only sends email to one address, the problem goes away. The email gets sent with no errors.

ivnish’s picture

+1

I get this error on webform submit

mr.pomelov’s picture

FileSize
45.24 KB

+1

I also get the "Invalid address" error. I tried to disable additional addresses and delete them, leaving one-the error does not disappear. I tried using the regular and DEV version of the SMTP module.

Despite the error, the emails are sent to several mailboxes.

Drupal core 7.80
SMTP Authentication Support 7.x-1.7+21-dev
Webform 7.x-4.24