Envoyer un message

Post /messages/send

Paramètres :

Nom Description Type Obligatoire
to

Tableau de destinataires

Nom Description Type Obligatoire
address String Oui
personalName String Non
Array Oui
msg
Nom Description Type Obligatoire
from
Nom Description Type Obligatoire
address String Oui
personalName String Non
Struct Non
subject String Non
replyTo
Nom Description Type Obligatoire
address String Oui
personalName String Non
Struct Non
html String Non
text String Non
attachments
Nom Description Type Obligatoire
content Encodé en base 64 String Non
filename String Non
type Type Mime String Non
Array Non
images
Nom Description Type Obligatoire
contentType Encodé en base 64 String Non
filename String Non
type Type Mime String Non
contentId Id du contenu où placer l'image String Non
Array Non
Struct Oui
headers Header au format JSON Struct Non
apiKey Id de la clé API utilisée pour envoyer les emails. Si vide nous utilisons la clé servant à l'authentification. String Non

Réponse :

Nom Description Type
status success / failure String

PHP : Avec une librairie dédiée

Attention : le code PHP suivant nécessite d'installer la librairie Tipimail. Pour cela téléchargez d'abord 'Composer' et ensuite dans le répertoire où est enregistré votre script, exécutez dans votre Invite de commandes la ligne suivante : composer require tipimail/tipimail
Langage de programmation :

Exemple de requête :

							{
								"to": [
									{
										"address":"to1@example.com",
										"personalName":"Nameto1"
									},
									{
										"address":"to2@example.com",
										"personalName":"Nameto2"
									}
								],
								"msg": {
									"from": {
										"personalName": "Fromname",
										"address": "from@example.com"
									},
									"replyTo": {
										"personalName": "Replytoname",
										"address": "reply@example.com"
									},
									"subject": "Subject",
									"text": "Text content",
									"html": "

Html content

", "images": [ { "contentType": "image/png", "filename": "IMAGECID", "content": "azerty" } ], "attachments": [ { "contentType": "text/plain", "filename": "myfile.txt", "content": "azerty" } ], }, "headers": { "X-TM-META": { "orderId": 123456789, "shipmentId": 123456789 }, "X-TM-SUB": [ { "email":"email1@example.com", "values": { "firstName": "Name1", "uniqueId": 132456798 } }, { "email":"email2@example.com", "values": { "subject": "mon mail numero 2", "firstName": "Name2", "meta": { "uniqueId": 987654321, "orderId": 132456798, "shipmentId": 1237498798 } } } ], "X-TM-TAGS": ["welcome", "website1"] } }

Exemple de réponse :

							{
								"status": "success"
							}
							

Exemple de code :

								curl -X POST -d '{"to":[{"address":"to@example.com"}], "msg":{"from":{"address":"from@example.com"},"subject":"My subject","html":"Html message","text":"Text message"},"apiKey":"YOUR_API_KEY"}' -H "Content-Type:application/json" -H "X-Tipimail-ApiUser:YOUR_SMTP_USERNAME" -H "X-Tipimail-ApiKey:YOUR_API_KEY" https://api.tipimail.com/v1/messages/send

							
require 'vendor/autoload.php';

$tipimail = new Tipimail\Tipimail('YOUR_SMTP_USERNAME', 'YOUR_API_KEY');

try {
	
	$data = new Tipimail\Messages\Message();
	$data->addTo('to1@example.com', 'to1');
	$data->addTo('to2@example.com', 'to2');
	$data->addTo('to3@example.com', 'to3');
	$data->deleteTo('to2@example.com');
	$data->setFrom('from@example.com', 'from1');
	$data->setSubject('Sujet');
	$data->setReplyTo('reply@example.com', 'reply');
	$data->setHtml('Your html content');
	$data->setText('Your text content');
	$data->setApiKey('Your api key');
	$data->addAttachmentFromText('text1 content', 'text1.txt');
	$data->addAttachmentFromText('text2 content', 'text2.txt');
	$data->addAttachmentFromText('text3 content', 'text3.txt');
	$data->addAttachmentFromBase64('dGV4dDMgY29udGVudA==', 'text4.txt', 'text/plain');
	$data->deleteAttachment('text2.txt');
	$data->addImageFromBase64('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=', 'image1.png', 'image/png', 'id1');
	$data->addImageFromBase64('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=', 'image2.png', 'image/png', 'id2');
	$data->addImageFromBase64('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=', 'image3.png', 'image/png', 'id3');
	$data->addImageFromFile('path\to\file\test.png', 'image4.png', 'id4');
	$data->deleteImage('image2.png');
	$data->addAttachmentFromFile('path\to\file\text.txt', 'text5.txt');
	$data->addAttachmentFromFile('path\to\file\doc.docx', 'doc1.docx');
	$data->setDomain('example.com');
	$data->enableTrackingOpen();
	$data->disableTrackingOpen();
	$data->enableTrackingClick();
	$data->disableTrackingClick();
	$data->enableGoogleAnalytics('sourceExample', 'mediumExample', 'contentExample', 'campaignExample');
	$data->disableGoogleAnalytics();
	$data->addTag('test1');
	$data->addTag('test2');
	$data->addTag('test3');
	$data->deleteTag('test2');
	$data->setMeta(array('order_id' => '123456789', 'shipment_id' => '1326548'));
	$data->enableBulk();
	$data->disableBulk();
	$data->setIpPool('192.168.1.1');
	$data->enableTextVersion();
	$data->disableTextVersion();
	$data->setBlacklist('blacklistName');
	$data->setTemplate('templateName');
	$data->addSub('to1@example.com', array('first_name' => 'Firstname1', 'last_name' => 'Lastname1'), array('order_id' => '1', 'shipment_id' => '1'));
	$data->addSub('to2@example.com', array('first_name' => 'Firstname2', 'last_name' => 'Lastname2'), array('order_id' => '2', 'shipment_id' => '2'));
	$data->addSub('to3@example.com', array('first_name' => 'Firstname3', 'last_name' => 'Lastname3'), array('order_id' => '3', 'shipment_id' => '3'));
	$data->deleteSub('to2@example.com');
	$tipimail->getMessagesService()->send($data);
	
	/*
	
	****************************************************************
	****************************************************************

	"CC" and "BCC" not available, please contact us for a workaround

	****************************************************************
	****************************************************************

	$data->addCc('cc1@example.com', 'cc1');
	$data->addCc('cc2@example.com', 'cc2');
	$data->addCc('cc3@example.com', 'cc3');
	$data->deleteCc('cc2@example.com');
	$data->addBcc('bcc1@example.com', 'bcc1');
	$data->addBcc('bcc2@example.com', 'bcc2');
	$data->addBcc('bcc3@example.com', 'bcc3');
	$data->deleteBcc('bcc2@test.fr');

	****************************************************************
	****************************************************************

	"CC" and "BCC" not available, please contact us for a workaround

	****************************************************************
	****************************************************************
	
	*/
		
}
catch(Tipimail\Exceptions\TipimailException $e) {
	echo 'Exception received :', $e->getMessage(), "\n";
	
}

...

public class Example {
	
	public static void main(String[] args) {
		
		Tipimail tipimail = new Tipimail("YOUR_SMTP_USERNAME", "YOUR_API_KEY");
		
		try {
			
			essage data = new Message();
			data.addTo("to1@example.com", "to1");
			data.addTo("to2@example.com", "to2");
			data.addTo("to3@example.com", "to3");
			data.deleteTo("to2@example.com");
			data.addCc("cc1@example.com", "cc1");
			data.addCc("cc2@example.com", "cc2");
			data.addCc("cc3@example.com", "cc3");
			data.deleteCc("cc2@example.com");
			data.addBcc("bcc1@example.com", "bcc1");
			data.addBcc("bcc2@example.com", "bcc2");
			data.addBcc("bcc3@example.com", "bcc3");
			data.deleteBcc("bcc2@example.com");
			data.setFrom("from@example.com", "from1");
			data.setSubject("Sujet");
			data.setReplyTo("reply@example.com", "reply");
			data.setHtml("Your html content");
			data.setText("Your text content");
			data.setApiKey("Your api key");
			data.addAttachmentFromText("text1 content", "text1.txt");
			data.addAttachmentFromText("text2 content", "text2.txt");
			data.addAttachmentFromText("text3 content", "text3.txt");
			data.addAttachmentFromBase64("dGV4dDMgY29udGVudA==", "text4.txt", "text/plain");
			data.deleteAttachment("text2.txt");
			data.addImageFromBase64("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=", "image1.png", "image/png", "id1");
			data.addImageFromBase64("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=", "image2.png", "image/png", "id2");
			data.addImageFromBase64("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=", "image3.png", "image/png", "id3");
			data.deleteImage("img2.jpg");
			data.setDomain("example.com");
			data.enableTrackingOpen();
			data.disableTrackingOpen();
			data.enableTrackingClick();
			data.disableTrackingClick();
			data.enableGoogleAnalytics("sourceExample", "mediumExample", "contentExample", "campaignExample");
			data.disableGoogleAnalytics();
			data.addTag("test1");
			data.addTag("test2");
			data.addTag("test3");
			data.deleteTag("test2");
			HashMap<String, String> meta = new HashMap<String, String>();
			meta.put("order_id", "123456789");
			meta.put("shipment_id", "1326548");
			data.setMeta(meta);
			data.enableBulk();
			data.disableBulk();
			data.setIpPool("192.168.1.1");
			data.enableTextVersion();
			data.disableTextVersion();
			data.setBlacklist("blacklistName");
			data.setTemplate("templateName");
			HashMap<String, String> sub1Values = new HashMap<String, String>();
			sub1Values.put("first_name", "Firstame1");
			sub1Values.put("last_name", "Lastname1");
			HashMap<String, String> sub1Meta = new HashMap<String, String>();
			sub1Meta.put("order_id", "1");
			sub1Meta.put("shipment_id", "1");
			data.addSub("to1@example.com", sub1Values, sub1Meta);
			HashMap<String, String> sub2Values = new HashMap<String, String>();
			sub2Values.put("first_name", "Firstame1");
			sub2Values.put("last_name", "Lastname1");
			HashMap<String, String> sub2Meta = new HashMap<String, String>();
			sub2Meta.put("order_id", "2");
			sub2Meta.put("shipment_id", "2");
			data.addSub("to2@example.com", sub2Values, sub2Meta);
			HashMap<String, String> sub3Values = new HashMap<String, String>();
			sub3Values.put("first_name", "Firstame1");
			sub3Values.put("last_name", "Lastname1");
			HashMap<String, String> sub3Meta = new HashMap<String, String>();
			sub3Meta.put("order_id", "3");
			sub3Meta.put("shipment_id", "3");
			data.addSub("to3@example.com", sub3Values, sub3Meta);
			data.deleteSub("to2@example.com");
			tipimail.getMessagesService().send(data);
		
		}
		catch (TipimailException e) {
			
		}
	
	}
	
}