I created a custom EmailWebformHandler handler, despite putting inside the sendMessage method $message['attachments'] = drupal_realpath('private://sample.pdf'); the e-mail did not contain my attachment.

Looking at hook_mail and hook_mail_alter I could not find $message['attachments']

Comments

jrockowitz created an issue. See original summary.

jrockowitz’s picture

StatusFileSize
new1.9 KB
perignon’s picture

Thanks for the patch!

  • Perignon committed 85fff08 on 8.x-1.x authored by jrockowitz
    Issue #2983707 by jrockowitz: Webform attachments don't get sent using...
no sssweat’s picture

I put the patch inside the sendgrid_integration module folder.

when I try git apply -v sendgrid_integration-2983707-2.patch

I'm getting:

Checking patch src/Plugin/Mail/SendgridMail.php...
error: while searching for:
use Drupal\Core\Mail\MailInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueFactory;
use Html2Text\Html2Text;
use SendGrid\Client;
use SendGrid\Email;

I am applying the patch against the latest dev version. Also, tried applying it to the latest stable version, but same result.

no sssweat’s picture

Status: Needs review » Needs work
no sssweat’s picture

Status: Needs work » Needs review

Never mind, turns out the patch has already been committed to the latest dev. Thus, I was trying to apply a patch that was already applied.
Also, it's was my first time using windows patch command which doesn't tell you anything when it gets applied, so turns out my stable version also already was patched.

no sssweat’s picture

I'm getting a weird error

Error: Class 'SendGrid\Client' not found in Drupal\sendgrid_integration\Plugin\Mail\SendGridMail->mail() (line 148 of modules/sendgrid_integration/src/Plugin/Mail/SendgridMail.php).

But I see the use SendGrid\Client; at the top. What the...

no sssweat’s picture

Status: Needs review » Needs work
no sssweat’s picture

Status: Needs work » Needs review

Oh I see now, I now remember my client did not want to use composer, so I had to patch this. Which explains why the patch was failing to apply on stable.

no sssweat’s picture

Status: Needs review » Needs work

@jrockowitz did you remember to remove the form alter that you added to webform.module on sendgrid integration's behave?

Because when I remove it, I no longer get attachments on the e-mail, so seems like the #2 patch is not working.

perignon’s picture

The patch did not apply because it has already been committed against the branch if you are using the latest dev.

Not use composer with D8? Good luck! I cannot seem to get around composer and do everything command line like I did in D7 days.

no sssweat’s picture

@Perignon, I normally would use composer, but since we're using Pantheon, using composer would destroy the 1 click updates feature, which my client wants to have.

Partial Composer adoption for Drupal 8 sites is not supported since Composer is used by core, meaning any change to composer.json or the vendor directory would result in massive merge conflicts when trying to update core via one-click updates in the Pantheon Site Dashboard.

Luckly, this is the only module that we need that relies on composer, so we'll be fine.

ruslan piskarov’s picture

@No Sssweat,
On Pantheon you can use "terminus composer YOU-SERVER-NAME.dev require drupal/sendgrid_integration".

ruslan piskarov’s picture

Status: Needs work » Fixed

I tested the patch and works great. Moving to Fixed as the patch was committed to dev.

Status: Fixed » Closed (fixed)

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

rpayanm’s picture

The keys filepath and file inside the $attachment var do not exist anymore.

rpayanm’s picture

StatusFileSize
new4.04 KB

This patch fixed that.

ruslan piskarov’s picture

Hey @rpayanm. This issue was closed 2 years ago. I think you can create a new one.

nicholass’s picture

#18 @rpayanm worked for me locally(DDEV), but for some reason it doesn't on our Acquia servers. Any ideas why?

I am wondering if it has something to do if the webform attachments are private files, would that be why they are not being sent via sendgrid?

nicholass’s picture

So it turns out my issue was also related to this webforms issues related to memecache for anyone else having trouble with attachments. Downgrading to memcache 2.1 did the trick, and that explains why attachments worked on my local.

https://www.drupal.org/project/memcache/issues/3176519

So patch #18 does in fact work! Thanks!