I am trying to send a contact email through my website, but the following error:

Asked

Viewed 35 times

-2

Notice: Array to string Conversion in C: Uwamp www Site processa.php on line 29

<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php

        $titulo = $_POST['titulo'];
        $nome = $_POST['nome'];
        $email = $_POST['email'];
        $mensagem = $_POST['mensagem'];

        require 'vendor/autoload.php';

        $from = new SendGrid\Email(null, $email);
        $subject = "Confirmar email";
        $to = new SendGrid\Email(null, "[email protected]");
        $content = new SendGrid\Content("text/html", "Olá, Equipe de suporte do Fusion.<br><br>$titulo<br>Nome: $nome<br>Email: $email<br> Mensagem: $mensagem");
        $mail = new SendGrid\Mail($from, $subject, $to, $content);

        //Necessário inserir a chave
        $apiKey = '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';
        $sg = new \SendGrid($apiKey);

        $response = $sg->client->mail()->send()->post($mail);
        echo $response->statusCode();
        echo $response->headers();
        echo $response->body();
        ?>
    </body>
</html>

1 answer

1

The method echo $response->headers(); take array and no string, then use ECHO does not work, use print_r or var_dump, like this:

echo $response->statusCode();
var_dump($response->headers());
echo $response->body();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.