Send message

Post /messages/send

Parameters:

Name Description Type Mandatory
to

An array of recipient information

Name Description Type Mandatory
address String Yes
personalName String No
Array Yes
msg
Name Description Type Mandatory
from
Name Description Type Mandatory
address String Yes
personalName String No
Struct No
subject String No
replyTo
Name Description Type Mandatory
address String Yes
personalName String No
Struct No
html String No
text String No
attachments
Name Description Type Mandatory
content Encoded on base 64 String No
filename String No
type Mime type String No
Array No
images
Name Description Type Mandatory
contentType Encoded on base 64 String No
filename String No
type Mime type String No
contentId Content Id where to place the image String No
Array No
Struct Yes
headers Header on JSON format Struct No
apiKey Id of the api key used to send emails. If empty, we used apikey from authentication String No

Response:

Name Description Type
status success / failure String

PHP : With a dedicated library

Attention : the following PHP code require to install the Tipimail's library. For this, download and install 'Composer' and then in the folder where your script is saved, execute in the terminal console the following line : composer require tipimail/tipimail
Programming language:

Request exemple:

							{
								"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"] } }

Response exemple:

							{
								"status": "success"
							}
							

Code example:

								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) {
			
		}
	
	}
	
}