</code>Using rules to attach and send a file via sendgrid integration API doesn't seem to work. It works fine using SMTP, but when switching your site to use the API it will send the email without the file attached.
The current configuration I was using is: MailSystem module, Rules, Sendgrid Integration module with an API key, (also webform and fillPDF, but that shouldn't be relevant).
Background: when a user filled a webform and submitted, Rules would grab the webform data, fill out a PDF, attach it to an HTML email and send it out.
The problem was that the e-mail would go through, but the attachment wouldn't be attached when receiving it.
The issue seemed to be that drupal / rules was sending the attachment data as $message['params']['attachments'], and sendgrid integration module was expecting it as $message['attachments'] (this is evident in sendgrid_integraiton/inc/sendgrid.mail.inc file on line 308)
In order to fix this I generated a new class .inc file with MailSystem (which generates a file in files/mailsystem folder), and overwrote the public mail function in it with the following (relevant part is bolded):
public function mail(array $message) {
/** fix the missing attachments problem **/
<code>
if(!empty($message['params']['attachments'])){
$message['attachments'] = $message['params']['attachments'];
foreach($message['attachments'] as $key => $value){
if(!empty($value['filepath'])){
$message['attachments'][$key] = $value['filepath'];
}
}
}
/** fix the reply-to problem **/
if(!empty($message['params']['reply-to'])){
$message['headers']['Reply-To'] = trim($message['params']['reply-to']);
}
return $this->mailClass->mail($message);
}
A more permanent fix would be to modify the inc/sengrid.mail.inc file on line 306 to see if $message['params']['attachments'] was empty or not and, if not, to add it's contents to the $message['attachments'] array in the appropriate format.