It's a one-liner fix.

Wrong:
t('The following From address failed: !from', array('!from' => $smtp_from)),

Right:
t('The following From address failed: @from', array('@from' => $smtp_from)),

See also:
https://www.drupal.org/node/2575819

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cppg created an issue. See original summary.

estoyausente’s picture

Changed all !var placeholders and replaced with @var in t functions.

cppg’s picture

It's not ok, I'm afraid. @!smail is not a correct syntax, it should be @smail.
First 4 lines are not ok, last 2 are ok.

estoyausente’s picture

Status: Needs review » Needs work

Yo're right!. I will be do asap.

pawel_r’s picture

Thx #2.
After applying this patch e-mails from Contact Forms are being send properly.
Drupal 8.2

mgoncalves’s picture

Assigned: Unassigned » mgoncalves
mgoncalves’s picture

The issue reported was fixed, but I have a question about the t() function.
In this case, should I use the $this->t() or keep only t() ?

mgoncalves’s picture

Assigned: mgoncalves » Unassigned
Status: Needs work » Needs review
gg24’s picture

Hi @mgoncalves,

It should be this->t() as t() has been deprecated and will be removed in Drupal 9.

Thanks!

gg24’s picture

Status: Needs review » Needs work
mgoncalves’s picture

Assigned: Unassigned » mgoncalves
estoyausente’s picture

@mgoncalves you cannot use $this->t because the code inside SMTP class is an external library, not a real Drupal class. Set inside this file a Drupal t function is a dirty way of resolve a problem that have to be resolve including the original library using composer or something similar.

@see https://www.drupal.org/node/2711559

mgoncalves’s picture

Hello @estoyausente,

I thought about that, Drupal 8 is keeping some hooks, and we cannot use $this->t inside hooks as well, do you ?
At this bug, the only thing I have seen is about the change from ! to @.

Do you have any point to add or the last patch I sent is satisfacting ?

estoyausente’s picture

The last past seems perfect but (viewing the code) but I haven't enough time to test in in my local environment. For this reason I don't change the issue status to RTBC :-)

estoyausente’s picture

Status: Needs work » Needs review
gg24’s picture

Hi @mgoncalves,

Your patch works as intended.

Thanks!

gg24’s picture

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

Assigned: mgoncalves » Unassigned
arnoldbird’s picture

Looks like this patch has not been applied to the dev branch yet.

arnoldbird’s picture

Version: 8.x-1.0-beta2 » 8.x-1.x-dev
arnoldbird’s picture

The patch in #7 is working for me. I no longer get the relevant error when I apply the patch to the latest dev code.

I can't send emails yet, but I think that's due to an unrelated issue.

wundo’s picture

Patch needs a re-roll, I'm going to manually fix it and commit.

wundo’s picture

wundo’s picture

  • wundo committed 35c4555 on 8.x-1.x
    Issue #2843350: Fixes improper t() usage inside AddAnAddress method
    
  • wundo committed 88213fd on 8.x-1.x
    Issue #2843350: Fixes improper t() usage
    
  • wundo committed aced43d on 8.x-1.x
    Issue #2843350: Fixes improper t() usage inside SetFrom method
    
wundo’s picture

Status: Needs review » Reviewed & tested by the community

As everything passed, I think this new patch is good to go :)

  • wundo committed 66a7035 on 8.x-1.x
    Issue #2843350 by mgoncalves, estoyausente, wundo, gg24, cppg,...
wundo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

pianomansam’s picture

Can we can a full release with this fix? It's been 12 months since it was committed to dev.

lukus’s picture

+1 for release