PHP code example of manlikeangus / zeptomail

1. Go to this page and download the library: Download manlikeangus/zeptomail library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manlikeangus / zeptomail example snippets

 
// doing your own loading:
oloading: 
 
//create a new message object
$msg = new \stdClass();

//dy = "My text-only message"; //TEXT MSG, NULL IF sending HTML
$msg->htmlbody = "<p>My HTML-formatted message</p>"; //HTML MSG, NULL if sending TEXT
$msg->to = array('[email protected]','Joe Customer'); //TO
$msg->from = array('[email protected]','XYZ Company'); //FROM

//instantiate library and pass info
$tmail = new \ZeptoMail\ZeptoMailClient($msg);

//send the message
$response = $tmail->send();

if ($response) {
    // success
} 
else  {
    // failure
}
 
$msg->to = '[email protected]'; 
//or
$msg->to = array('[email protected]','Joe Customer');
 
	//create a new message object
	$msg = new \stdClass();
	
	// = "My text-only message"; //TEXT MSG, NULL IF sending HTML
	$msg->htmlbody = "<p>My HTML-formatted message</p>"; //HTML MSG, NULL if sending TEXT
	$msg->to = array('[email protected]','Joe Customer'); //TO
	$msg->from = array('[email protected]','XYZ Company'); //FROM
	
	//optional settings
	$msg->reply_to = array('[email protected]','XYZ Company'); //REPLY TO
	$msg->cc = array('[email protected]','Someone'); //CC
	$msg->bcc = array('[email protected]','Somebody Else'); //BCC
	$msg->track_clicks = TRUE; //TRACK CLICKS, TRUE by default
	$msg->track_opens = TRUE; //TRACK OPENS, TRUE by default
	$msg->client_reference = NULL; //CLIENT ID (string)
	$msg->mime_headers = NULL; //ADDITIONAL MIME HEADERS (array)
	$msg->attachments = NULL; //ATTACHMENTS (array)
	$msg->inline_images = NULL; //INLINE IMAGES (array)
	
	//instantiate library and pass all possible settings
	$tmail = new \ZeptoMail\ZeptoMailClient($msg, "myapikey", "[email protected]", TRUE);
	
	//send the message
	$response = $tmail->send();
			
	if ($response) {
            // success
        } 
	else {
            // failure
        }
 
$headers = array();
$headers[] = array( "CustId" => "1234", "CustName" => "Bob Smith" );
 
$attachments = array();

$file = "filename.jpg";
$path = "/path/to/" . $file;
$filedata = file_get_contents($path);

if ($filedata) {
    $base64 = base64_encode($filedata);
    $attachments[] = array( "content" => $base64, "mime_type" => mime_content_type($path), "name" => $file );
}