Solved

Azure Website PHP - Using Curl

Posted on 2014-12-03
11
361 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Office 365 Advanced Training for Admins

Special Offer:  Buy 1 course, get 2nd free!  Buy the 'Managing Office 365 Identities & Requirements' course w/ Accelerated TestPrep, and automatically receive the 'Enabling Office 365 Services' course FREE!

Question has a verified solution.

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

Suggested Solutions

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…
Or at least that’s the word according to a new blog from Tech Target on AWS’s new Managed Services (MS) offering. According to the blog, AWS is launching their AWS MS program to expedite the adoption of cloud by Fortune 1000 and Global 2000 companie…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

737 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