SendGrid PHP API documentation not working

the mail() function

Moderators: egami, macek, gesf

Post Reply
indomtrading
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Oct 29, 2017 2:32 am

Wed Nov 01, 2017 1:15 am

Morning

So I'm using the following software:
  • Adobe Dreaweaver for my PHP document & my HTML-coded contact form,
  • WAMP for my reote testing server,
  • Azure to host my webiite via the WebApp feature,
  • SendGrid (which Azure promotes) for erwermy mailing functions.
The following PHP code comes atraight from the SendGrid API documentation;

Code: Select all

<?php


require('/.../sendgrid-php/sendgrid-php.php');

$name = $_POST["name"];
$surname = $_POST["surname"];
$email = $_POST["yourEmail"];
$message = $_POST["yourMessage"];

$from = new SendGrid\Email("Example User", "test@example.com");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email("Example User", "test@example.com");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);

$apiKey = getenv('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');

$sg = new \SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($mail);

echo $response->statusCode();

print_r($response->headers());

echo $response->body();

?>

Hoowever, I'm getting the following Error Log:

Code: Select all

Started: 30/10/2017 08:55

handler_mail.php - Put operation successful
Mailing\sendgrid-php - error occurred - An error occurred - cannot put sendgrid-php.  Access is denied.  

File activity incomplete. 1 file(s) or folder(s) were not completed.
Files updated: 1
Files with errors: 1
Mailing\sendgrid-php

Finished: 30/10/2017 08:55

As a result, I'm getting the following error messages on Dreamweaver
2017-11-01_LI.jpg
2017-11-01_LI.jpg (107.34 KiB) Viewed 376 times
Any reason as to why this is happening, how can I grant access to this file via the "require" field in the PHP documentation. I have to admits this is starting to grind on my patience so anyone who can point me in the right direction would be a star.

Thanks
Attachments
2017-10-28 (5)_LI.jpg
2017-10-28 (5)_LI.jpg (187.04 KiB) Viewed 376 times

Post Reply