joelcox / codeigniter-amazon-ses

A CodeIgniter library to interact with Amazon Web Services (AWS) Simple Email Service (SES)
http://joelcox.nl
MIT License
79 stars 31 forks source link

cURL issue #2

Closed rezzz-dev closed 13 years ago

rezzz-dev commented 13 years ago

Not sure if this should be posted here or on Phil's but I seem to be getting this error when trying to run this.

A PHP Error was encountered

Severity: Warning

Message: curl_close(): supplied argument is not a valid cURL handle resource

Filename: libraries/Curl.php

Line Number: 312

Not sure what to do, would appreciate any help that you can give, thanks

joelcox commented 13 years ago

Thanks for your report. Can you please post a bit of your code when this error occurs? Does your error log show anything abnormal and did you try to enable debug mode? $this->amazon_ses->debug();

rezzz-dev commented 13 years ago

This is the code I have in there - I took out the emails so I don't get slammed with garbage.

$to = 'email@domain.com';
$body = "Just a reminder that you have an appointment tomorrow";
$this->amazon_ses->debug();
$this->amazon_ses->from('(validemail)','(validName)');
$this->amazon_ses->to($to);
$this->amazon_ses->message($body);
$this->amazon_ses->send();

I even looked in the apache error logs and nothing shows up, which I find really strange. I do appreciate any help, thanks @joelcox

joelcox commented 13 years ago

Hmm, that should work okay. What happens when you var_dump($this->amazon_ses->send());

rezzz-dev commented 13 years ago

Hmmm -- Phil said that he made some changes to his library but intro'd a bug and hasn't fixed it - so I'm not sure if it's his issue now or not. Do you have the Curl.php lib that works with it?

joelcox commented 13 years ago

I'm using the version on GetSparks.org, which is tagged as v1.0 on GitHub. https://github.com/philsturgeon/codeigniter-curl/tree/1.0. Please let me know if using this version resolves your problem.

rezzz-dev commented 13 years ago

Nope - I get nothing now - ugh - don't understand this - I don't see anything in error log or anything - just a 200 in access

joelcox commented 13 years ago

Could you post the content of your CodeIgniter logs? (http://codeigniter.com/user_guide/general/errors.html)

rezzz-dev commented 13 years ago

When I do a var_dump($this->amazon_ses->send()) - I get bool(false)

rezzz-dev commented 13 years ago

I just turned on the error logging and but no log file was created - I think it's because it's actually returning false from the send - not sure why though - where does the debug() drop the info for the SES lib?

rezzz-dev commented 13 years ago

Ok -- I've got the error finally :) Peer certificate cannot be authenticated with known CA certificates

I even went into your lib and pulled out the https to just use http - but then I get couldn't connect to host

Now what's the deal there? -- It's the same thing that I've been using on the command line scripts. Any thoughts?

rezzz-dev commented 13 years ago

@joelcox - not sure if this is good or not - but I changed the VERIFYPEER from TRUE to FALSE in the Curl.php lib, but now it's sending and working

I'd love to hear your thoughts on that - thanks again

joelcox commented 13 years ago

@rezzz-dev Most PHP/cURL libs can't access SSL certificates installed on the system. This makes it impossible to check whether a connection to SES has been compromised. Since you're sending email addresses over the internet, I made a secured connection mandatory. You can specify the location of these certificates using

$config['amazon_ses_cert_path'] = 'location/to/certs.pem';

I will add an extra check for this in the library so it will warn you instead of fail bluntly. Sorry for your experience!

This is related to Issue 1

rezzz-dev commented 13 years ago

It's totally all good, no sweat. Thanks for all your effort!! I put the location in there just as you state in the config, but still was getting that issue. No clue as to why it maybe wasn't finding it, perms? So what I did was copied the cert into the config dir, changed the perms on it to 777 and still got that error. So instead I just changed the value for verifying in the curl lib to false. Not the best thing I know, but it works for the time being :).

joelcox commented 13 years ago

Hmm, the file only has to be readable. What certificate did you use? I recommend this one: http://www.cs.fsu.edu/~engelen/soapcacerts.html

joelcox commented 13 years ago

I updated the source to include the check in commit 5f7237815e39c2c76267. Could you get back to my previous message?

rezzz-dev commented 13 years ago

I was using my AWS cert - it did work once I got Phil's lib working - thanks so much