PHP JSON Setrow e-mail integration
Setrow is one of the companies providing email marketing services and has a reliable infrastructure in digital marketing.
It is very effective against the spam mail problem that may occur during mass mail sending via standard servers.
For detailed information about Setrow products and services, you can visit https://www.setrow.com/.
In this article I will talk about setrow mail integration.
First of all, you need to be a setrow subscriber and need the necessary authorization and session codes for the services, after completing the requirements, you need to examine the codes below and send the data to the relevant setrow address.
<?php
$api_key = 'xxxxx';
$trans_kod = 'xxxxx';
$post_url = 'http://www.setrowsend.com/email/send.php?k='.$api_key.'&transcode='.$trans_kod;
<!--We defined the setrow apikey, transcode, and the address we will post.-->
<!--$mailler In our variable, the array we created related to the e-mail addresses we received from the database is available.-->
foreach (array_chunk($emailler, 1000) as $loop) {
$o=array();
$post=array();
foreach ($loop as $i => $email) {
$micerik="YOU CAN ASSIGN EMAIL CONTENT FROM YOUR DATABASE TO THIS VARIABLE.";
$o['gonderen_adi']="MAIL SENDER";
$o['adres']=$email['Email'];
$s['subject']=$bulten['email_baslik'];
$s['content']=$micerik;
$alan=$s;
$o['alanlar']=$alan;
$post[]=$o;
}
$poststring = json_encode($post);
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
$result_decode = json_decode($result, true); //var_dump($result_decode);
$adres = $result_decode[0]['adres'];
$status= $result_decode[0]['durum'];
echo "Status: ".$status;
if($durum == 'fail'){
$error_detail = $result_decode[0]['error_detail'];
echo "<br />Error Detail: ".$error_detail;
}
}
?>
In this system that basically uses json data, setrow asks you to send 1000's of json data. For example, if we have a newsletter subscription with 5500 mails, the code we create should create 5 thousand json and 1 500 json.
To do this, we can use the array_chunk function in php.
Then we send the request to the setrow send address with curl.
After sending the e-mail, you can view the status reports of your submissions from the setrow site.