-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBasicWithCustomHeaders.php
More file actions
36 lines (27 loc) · 1.21 KB
/
BasicWithCustomHeaders.php
File metadata and controls
36 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include_once(__DIR__ . "../../includes.php");
use Socketlabs\Message\BasicMessage;
use Socketlabs\Message\EmailAddress;
use Socketlabs\SocketLabsClient;
$client = new SocketLabsClient(exampleConfig::serverId(), exampleConfig::password());
//Build the message
$message = new BasicMessage();
$message->subject = "Sending An Email With Custom Headers";
$message->htmlBody = "<body><strong>Lorem Ipsum</strong></body>";
$message->plainTextBody = "Lorem Ipsum";
$message->from = new EmailAddress("from@example.com");
$message->addToAddress(new EmailAddress("recipient1@example.com", "Recipient #1"));
//Add custom headers to the message
//There are serveral ways to add custom fields to a message
$message->addCustomHeader("My-Header", "1...2...3...");
$message->addCustomHeader("Example-Type", "BasicWithCustomHeaders");
//OR
$message->customHeaders[] = new \Socketlabs\Message\CustomHeader("My-Header", "1...2...3...");
$message->customHeaders[] = new \Socketlabs\Message\CustomHeader("Example-Type", "BasicWithCustomHeaders");
//OR
$message->customHeaders = array(
"My-Header" => "1...2...3...",
"Example-Type" => "BasicWithCustomHeaders",
);
//Create the client and send the message
$response = $client->send($message);