2017-04-04 2 views
-1

J'utilise xpertmailer pour envoyer des e-mails directement au serveur SMTP distant suite à une recherche MX. Cela fonctionne très bien et fonctionne sur un ancien lecteur NAS à source fermée exécutant PHP4 et sur les boîtes PHP5 actuelles.PHP Direct SMTP Envoyer + Pièce jointe

<?php 

define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors 
require_once '/path-to/SMTP.php'; // path to 'SMTP.php' file from XPM4 package 

$f = '[email protected]'; // from mail address 
$t = '[email protected]'; // to mail address 

// standard mail message RFC2822 
$m = 'From: '.$f."\r\n". 
    'To: '.$t."\r\n". 
    'Subject: test'."\r\n". 
    'Content-Type: text/plain'."\r\n\r\n". 
    'Text message.'; 

$h = explode('@', $t); // get client hostname 
$c = SMTP::MXconnect($h[1]); // connect to SMTP server (direct) from MX hosts list 
$s = SMTP::Send($c, array($t), $m, $f); // send mail 
// print result 
if ($s) echo 'Sent !'; 
else print_r($_RESULT); 
SMTP::Disconnect($c); // disconnect 

?> 

J'essaie maintenant d'ajouter une pièce jointe, mais je n'ai aucune idée comment obtenir une pièce jointe à inclure et envoyés.

Quelqu'un at-il des idées comment je peux le faire?

Merci

+0

Avez-vous vérifié http://xpertmailer.sourceforge.net/documentation/? "Attacher" est le 5ème élément de la liste sur la gauche, et semble assez simple pour courir avec. –

Répondre

1

Exemple:

$m = new MAIL; 

// attach source 
$a = $m->Attach('text message', 'text/plain'); 

$f = '/path/image.gif'; 
// attach file '$f', disposition 'inline' and give a name 'photo.gif' with ID value (this ID value can be used in embed HTML images) 
$a = $m->Attach(file_get_contents($f), FUNC::mime_type($f), 'photo.gif', null, null, 'inline', MIME::unique()); 

echo $a ? 'attached' : 'error'; 
+0

Merci .. cela aide beaucoup :) – Rocket