Wrong credentials in sending mail using sendgrid
<p>This is the code for sending email using sendgrid i have correct api key still the browser displays error as </p>

<p><strong>HTTP/1.1 401 Unauthorized Server: nginx Date: Thu, 14 Jul 2016 08:14:32 GMT Content-Type: application/json Content-Length: 88 Connection: keep-alive {"errors":[{"message":"Permission denied, wrong credentials","field":null,"help":null}]}</strong></p>

<pre><code> &lt;?php
    require '/sendgrid-php/vendor/autoload.php';
    if(require("sendgrid-php/vendor/autoload.php"))
        {echo "path found";}

    sendemail('kanwararyan2@gmail.com','SEndgrid','kanwararyan1@gmail.com','HI');
    function sendemail($f,$s,$t,$m){

    $from = new SendGrid\Email(null, $f);
    $subject = $s;
    $to = new SendGrid\Email(null, $t);
    $content = new SendGrid\Content("text/plain", $m);
    $mail = new SendGrid\Mail($from, $subject, $to, $content);

    $apiKey = getenv('Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    $sg = new \SendGrid($apiKey);

    $response = $sg-&gt;client-&gt;mail()-&gt;send()-&gt;post($mail);
    echo $response-&gt;statusCode();
    echo $response-&gt;headers();
    echo $response-&gt;body();
}
?&gt;
</code></pre>