Skip to content

Auto-determine the mimetype on a attachment #967

@jiska78

Description

@jiska78

I'm using SendGrid on my website and it allows a user to attach a file to an email. I used to just have the code $email->addattachment($filename) which no longer works on the new version of SendGrid. The new format is this:

    $attachment = new Attachment();
    $attachment->setContent("xxxx");
    $attachment->setType("application/pdf");
    $attachment->setFilename("balance_001.pdf");
    $attachment->setDisposition("attachment");
    $attachment->setContentId("Balance Sheet");
    $mail->addAttachment($attachment);

My problem with that is, how am I possibly going to know what filetype the user uploads. It could be anything? Can't I just tell sendgrid to attach whatever file is uploaded to the email being sent?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions