I am trying to send email via mailhimp api version 3.0 in php but I have no luck. This is my code:
$postString = '{ "message": { "html": "this is the emails html content", "text": "this is the emails text content", "subject": "this is the subject", "from_email": " xxx@dyyy.sk ", "from_name": "John", "to_email": " aaa.bbb@gmail.com ", "to_name": "Anton", "track_opens": false, "track_clicks": false }}'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->api_endpoint); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, 'drewm:'.$this->api_key); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/vnd.api+json', 'Content-Type: application/vnd.api+json')); curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); $result = curl_exec($ch); echo $result;
What am I doing wrong?
source share