Intanto usa <?php e non <? (deprecato)
Codice PHP:
<?php
include "./phpmailer/class.phpmailer.php";
function send_mail($email, $subject="", $body_html="", $mittente="", $mail_mittente=""){
//istanziamo la classe
$messaggio = new PHPmailer();
if($body_html != "") {
$messaggio->IsHTML(true);
$messaggio->Body = $body_html;
//if($body_txt != "") $messaggio->AltBody = $body_txt;
}
else $messaggio->Body = $body_txt;
$messaggio->From = $mail_mittente;
$messaggio->FromName = $mittente;
$messaggio->AddReplyTo = $mail_mittente;
$messaggio->AddAddress($email);
$messaggio->Subject = $subject;
$messaggio->AddEmbeddedImage("prova.gif", "image_0", "", "base64", "image/gif");
if($messaggio->Send()) return true; else return false;
unset($messaggio);
}
if (send_mail("destinatario@provider.com", "Ciao", "E-mail mandata con php via smtp locale: immaggine allegata.", "Nome Cognome", "mittente@provider.com"))
echo "Messaggio Inviato correttamente"; else echo "Errore nell'invio del messaggio";
?>
Ovviamente prova.gif si trova nella stessa cartella del file .php
Mandate 10 mail su 10
Controlla che il tuo provider non ti segnali come spam...
Dimmi se funziona