← Back
Editing: mail.php
<?php require_once ('sendblue/Mailin.php'); $mailin = new Mailin('https://api.sendinblue.com/v2.0','ZCspnfWQ0aLMbEGX'); $mailto = "maxmurd@gmail.com"; $from = "maxm@rockpolis.net"; $smtp_headers = "MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sat, 11 Mar 2017 18:13:15 +0100 From: Max M - Rock Polis To: maxmurd@gmail.com Subject: test 2 Organization: =?UTF-8?Q?Rock_Polis_la_citt=C3=A0_del_rock?= Reply-To: maxm@rockpolis.net Mail-Reply-To: maxm@rockpolis.net Message-ID: X-Sender: maxm@rockpolis.net User-Agent: Roundcube Webmail/1.1.4 "; $f1 = strpos ($smtp_headers, ' From: ')+7; $f2 = strpos ($smtp_headers, ' To: '); $s1 = strpos ($smtp_headers, ' Subject: ')+10; $s2 = strpos ($smtp_headers, ' Organization: '); $fromName = substr ($smtp_headers, $f1, $f2-$f1); $subject = substr ($smtp_headers, $s1, $s2-$s1); $mail['to'] = array ($mailto=>""); $mail['from'] = array ($from, $fromName); $mail['replyto'] = array ($from, $fromName); $mail['subject'] = $subject; $mail['text'] = strip_tags ($msg_body); $mail['html'] = nl2br ($msg_body)."<br>1<br>".$from."<br>2<br>".$mailto."<br>3<br>".$recip."<br>4<br>".$subject."<br>5<br>".$smtp_headers; $mail['headers'] = array ("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2","X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"); //$mail['headers'] = $smtp_headers; var_dump ($mailin->send_email($mail)); exit; $email = "maxmurd@gmail.com"; $contenuto = "Test email\n\n"; $oggetto = "Test email ".date ("Y-m-d H:i"); $intestaz = "From: Max Murdock <".str_replace (' ', '', $email).">"; // Obtain file upload vars $fileatt = "images/testa_login.gif"; //$fileatt_type = $_FILES['fileatt']['type']; $fileatt_type = "image/gif"; $fileatt_name = "testa_login.gif"; //if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $intestaz .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $contenuto = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $contenuto . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $contenuto.= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } $contenuto = "This is the <h1>HTML</h1><br/> This is inline image 1.<br/> <img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/> Some text<br/> This is inline image 2.<br/> <img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/> Some more text<br/> Re-used inline image 1.<br/>\n\n"; $mail['to'] = array ($email=>"Maxmurd"); $mail['from'] = array ("maxm@rockpolis.net","Max M"); $mail['replyto'] = array ("maxm@rockpolis.net","Max M"); $mail['subject'] = $oggetto; $mail['text'] = strip_tags ($contenuto); $mail['html'] = $contenuto; $mail['headers'] = array("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2","X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"); var_dump ($mailin->send_email($mail)); //echo "<h1>OK</h1>"; ?>
Save File
Cancel