Solved

Azure Website PHP - Using Curl

Posted on 2014-12-03
11
313 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 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 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