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

Email sender errors when form includes array field #720

Closed
colinmeinke opened this Issue May 30, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@colinmeinke

colinmeinke commented May 30, 2016

When sending a form that includes array data email sender errors:

[2016-05-30 17:53:32] production.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /Users/colin/Dropbox/projects/cardconnect/statamic/core/Email/Sender.php:144

This is that method, which does not expect a field to include array data so throws when it tries to print an array as a string:

    private function getAutomagicEmail()
    {
        $html = '';
        $text = '';

        foreach ($this->message->data() as $key => $value) {
            $html .= "<strong>" . $key . "</strong>: " . $value . "<br><br>\n";
            $text .= $key . ": " . $value . "\n";
        }

        return [$html, $text];
    }
@baybara-pavel

This comment has been minimized.

baybara-pavel commented Nov 24, 2016

Just one string can solve this issue, but this is core Statamic component, and any updates brake this again :(

private function getAutomagicEmail()
    {
        $html = '';
        $text = '';

        foreach ($this->message->data() as $key => $value) {
            $value = is_array($value) ? implode(', ', $value) : $value;
            $html .= "<strong>" . $key . "</strong>: " . $value . "<br><br>\n";
            $text .= $key . ": " . $value . "\n";
        }

        return [$html, $text];
    }
@rrelmy

This comment has been minimized.

rrelmy commented Feb 16, 2017

Just having the same problem :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment