?
Solved

Azure Website PHP - Using Curl

Posted on 2014-12-03
11
Medium Priority
?
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 84

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 84

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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 84

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
 

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 84

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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
On Feb. 28, Amazon’s Simple Storage Service (S3) went down after an employee issued the wrong command during a debugging exercise. Among those affected were big names like Netflix, Spotify and Expedia.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 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