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
| <?php
require_once('class.phpmailer.php');
$destinataire='tonadresse@serveur.com';
set_time_limit(0);
if(isset($_POST['expediteur'])){
$mail = new PHPmailer();
$mail->IsHTML();
$mail->From=$_POST['expediteur'];
$mail->AddReplyTo($_POST['expediteur']);
$mail->AddAddress($destinataire);
$mail->Subject=@$_POST['subject'];
$mail->Body=htmlentities(@$_POST['message']);
if(isset($_FILES['attach']))
if(is_uploaded_file($_FILES['attach']['tmp_name']))
$mail->AddAttachment($_FILES['attach']['tmp_name'],$_FILES['attach']['name']);
if(!$mail->Send())
echo $mail->ErrorInfo; else
echo 'Mail envoyé avec succès.'
echo '<br/>';
unset($mail);
}
?>
<form method="post" action="" enctype="multipart/form-data">
Email: <input type="text" name="expediteur" value=""/><br/>
Sujet: <input type="text" name="subject" value=""/><br/>
Message: <br/>
<textarea cols="54" rows="16" name="message"></textarea><br/>
Pièce jointe: <input name="attach" type="file"/>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000"/><br/>
<br/>
<input type="submit" value="Envoyer"/><br/>
</form> |