Mail attachment


#1

I wrote such code for sending attachment, but I don’t receive attachment. I only receive empty email without attachment. I wonder where is the problem? Could you please have a look and give me response if file is attached correctly. I am not sure if file attachment is really fully implemented and tested in Spryker because I didn’t find any usages in Spryker’s core/default.

`public function sendBusinessLicenseFile(CompanyTransfer $companyTransfer): CompanyResponseTransfer
{
$mailTransfer = new MailTransfer();
$mailTransfer->setType(BusinessLicenseMailTypePlugin::MAIL_TYPE);
$mailTransfer->setCompany($companyTransfer);
$mailTransfer->setSubject($this->businessFileEmailSubject);

    $recipient = new MailRecipientTransfer();
    $recipient->setName($this->businessFileRecipientName);
    $recipient->setEmail($this->businessFileRecipientEmail);
    $mailTransfer->addRecipient($recipient);

    $fileUrl = $this->businessFileFilepath . '/' . $companyTransfer->getBussinessLicenseFile();
    $attachment = new MailAttachmentTransfer();
    $attachment->setAttachmentUrl($fileUrl);
    $attachment->setFileName($fileUrl);
    $attachment->setDisplayName($companyTransfer->getBussinessLicenseFile());

    $mailTransfer->addAttachment($attachment);

    $this->mailFacade->handleMail($mailTransfer);

    $response = new CompanyResponseTransfer();
    $response->setIsSuccessful(true);

    return $response;
}`

#2

So I can conclude that there is no working attachment functionality. I implemented it and created pull request for it, you can use it: