Solved

Azure Website PHP - Using Curl

Posted on 2014-12-03
11
379 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 83

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 83

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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 83

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 83

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 83

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 83

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 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