I was working on an app for a client and I needed to send email from localhost. The scripting language that I was using was php and I was using WAMP as my server. So the first thing I did was to download the sendgrid php api since I did not have composer. After unzipping the files I placed the sendgrid folder within the root of my project.
There is a nice example on the github page that you can use right away but first you need to setup a couple of things. At the top of the php file you need to add this line:
Now when you try to send email you will get this error:
cURL error 60: SSL certificate: unable to get local issuer certificate
Since we are sending from localhost we need to setup SSL. These steps apply to WAMP but I think you can easily apply them to other setups.
- Download the latest CA Certificate file from here.
- Now go to where ever you have installed wamp and place it under:
php.iniand find this line:
- Uncomment the above line and point it to the
cacert.pemfile you placed in step 2.
- Save the file and restart your WAMP server.
If you try to send mail it should work. For XAMPP server use this solution.