Solved

Azure Website PHP - Using Curl

Posted on 2014-12-03
11
302 Views
Last Modified: 2015-03-13
Hi I don't have any web building knowledge so if someone could cast an eye over my script for sending an email that would be great.

The site is hosted on Azure and I have setup a SendGrid account, the contact.php file I have created runs ok and redirects me to the thank you page but no email appears.

I will also attach the PHP error log.

Any help would be great thanks.
php-errors.log
contact.php
0
Comment
Question by:RedDoorSupplies
  • 6
  • 5
11 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40479421
I think you need to review your info from Sendgrid.  Your email headers and HTML formatting are out of order and that may be why your email is not being sent.
0
 

Author Comment

by:RedDoorSupplies
ID: 40480248
Ok thanks I have asked them to have a look at it but they haven't been able to get it to work so far.

Is there anything you can recommend I change to get it working?

Thanks
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40480279
Other than the out of order formatting, I don't know what to tell you.  Sendgrid wouldn't let me sign up with them as a developer so I don't have any of their docs.

Your PHP error log is pretty self-explanatory.  You have not defined the variable $subject before trying to use it.
0
 

Author Comment

by:RedDoorSupplies
ID: 40488566
Hi thanks I think I have successfully updated the script but still cant get it to send.

Do I need to activate the CURL on my Azure site that you know of as cant seem to find an answer for that.

Thanks
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40489627
No, the 'curl' that you are trying to use is part of PHP and I don't see an error message relating to it.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:RedDoorSupplies
ID: 40490728
Ok reason I mention it was of the following error

Use of undefined constant CURL_SSLVERSION_TLSv1_2 - assumed 'CURL_SSLVERSION_TLSv1_2' in D:\home\site\wwwroot\contact.php on line 49

Seems really strange ive been onto Microsoft and SendGrid but neither can get it working.

So you don't think I need to install anything onto my Azure websites server then?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40490745
If 'curl' was not installed with PHP, you would be getting a lot more error messages than that.  In addition, each version of PHP has a corresponding version of 'curl' and you can't update one without the other.  Post a copy of your current code and I'll take a look at it.
0
 

Author Comment

by:RedDoorSupplies
ID: 40490760
Ok that would be great thanks.

Ive attached a copy of the site which is a simple holding page with a contact form. I had to delete some of files like fonts etc as I wasn't able to upload here.

If you fill in the form and click submit the contact.php runs as you get redirected to the thank you page but that's it no email.

If that's not what you need let me know and will find some more info for you.

Many thanks
site.zip
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40490835
I just looked at the SendGrid page https://sendgrid.com/docs/API_Reference/Web_API/mail.html and it shows how to format the POST data to send an email.  You are nowhere close.  You are putting the 'params' in an array and I don't know why.  According to that page, it must be formatted as name/value pairs in standard POST format.  Where did you get that code?
0
 

Author Comment

by:RedDoorSupplies
ID: 40491040
I got the base code for the contact.php file from a SendGrid example sheet I then amended it instructed by SendGrid support to try and get it working.

This is the first time I have looked at editing web pages etc which is why im not 100% sure of the correct way to do it.

Is the format of my contact.php completely wrong then?
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40492339
The main thing that is wrong is that the POST data for cURL needs to be in 'name/value' pairs as shown on that page.  Putting a PHP array there is not likely to work.  Try the simple example code on that page and see if that works.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now