Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It will fix undefined index cid error when sending emails with embedded images #4798

Merged
merged 1 commit into from
Jun 8, 2021

Conversation

mmfarhan
Copy link
Contributor

@mmfarhan mmfarhan commented Jun 7, 2021

fix for undefined index cid error

Each pull request should address a single issue and have a meaningful title.

Description
Explain what you have changed, and why.

Checklist:

  • Securely signed commits

fix for undefined index cid error
@mmfarhan mmfarhan changed the title Update Email.php It will fix undefined index cid error when sending emails with embedded images Jun 7, 2021
@samsonasik samsonasik merged commit 34d74c7 into codeigniter4:develop Jun 8, 2021
@samsonasik
Copy link
Member

Thank you @mmfarhan

@vlakoff
Copy link
Contributor

vlakoff commented Aug 17, 2021

Alternatively, we could assign $attachment by reference:

    public function setAttachmentCID($filename)
    {
        foreach ($this->attachments as $i => &$attachment) {
            if ($attachment['name'][0] === $filename) {
                $attachment['multipart'] = 'related';

                $attachment['cid'] = uniqid(basename($attachment['name'][0]) . '@', true);

                return $attachment['cid'];
            }
        }
        unset($attachment);

        return false;
    }

(the unset() is not required here, but it's good practice, and emphasizes there is a reference)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants