M
M
make_luv2014-12-03 12:12:59
PHP
make_luv, 2014-12-03 12:12:59

Why is mail not sent from Azure via Sendgrid?

Hello.
There is a site on Azure with a feedback form, when submitting it via CURL, everything is transferred to Sendgrid, which directly sends it.
This is how sending mail to Azure is done, replacing the php mail().
The problem is that nothing is transferred to the sendgrid. I checked the code on other hostings - everything is ok, Sendgrid receives data and the letter arrives, but it does not work on Azure.
Here is the script that does the transfer:
<?php
// use actual sendgrid username and password in this section
$url = ' https://api.sendgrid.com/ ';
$user = '******'; // place SG username here
$pass = '******'; // place SG password here
// grabs HTML form's post data; if you customize the form.html parameters then you will need to reference their new new names here
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// note the above parameters now referenced in the 'subject', 'html', and 'text' sections
// make the to email be your own address or where ever you would like the contact form info sent
$params = array(
' api_user' => "$user",
'api_key' => "$pass",
'to' => "*@***.**", // set TO address to have the contact form's email content sent to
'subject' => "Contact Form Submission", // Either give a subject for each submission, or set to $subject
'html' => " Contact Form
Name: $name\n
Email: $email\n
Subject: $subject \n
Message: $message ", // Set HTML here. Will still need to make sure to reference post data names
'text' => "
Name: $name\n
Email: $email\n
Subject: $subject\n
$message",
'from' => "[email protected] ", // set from address here, it can really be anything
);
$request = $url.'api/mail.send.json';
curl_setopt($session, CURLOPT_SSLVERSION, 6);
// Tell curl to use HTTP POST
curl_setopt($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// Redirect to thank you page upon successfull completion, will want to build one if you don't alreday have one available
//header('Location: thanks.html'); // feel free to use whatever title you wish for thank you landing page, but will need to reference that file name in place of the present 'thanks.html'
exit();
// print everything out
print_r($response);
?>
In msdn it is recommended to write a ticket, but in order to get help from a debility ms you need to buy a support plan, which you don’t want to buy at all, because. nothing works.
We talked with Sendgrid support for a week, and eventually found out that the problem was on the MS side.
I repeat - the code is working, for example, it works. There are no errors in php log on Azura.
Has anyone experienced similar behavior with Azure Websites?
I would be very grateful for any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
make_luv, 2014-12-19
@make_luv

The question was solved by rewriting on .NET.
PHP - in the oven.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question