source: spip-zone/_plugins_/_email_/phpmailer/phpmailer.html @ 4294

Last change on this file since 4294 was 4294, checked in by booz@…, 14 years ago

exemple d'email evoye par smtp

File size: 1.6 KB
Line 
1<?php
2
3// Ce squelette permet de tester le code sur son hebergeur
4
5include_spip('class.phpmailer');
6include_spip('class.smtp');
7
8
9$mail = new PHPMailer();
10
11$mail->IsSMTP();
12$mail->Host='smtp.machin.com';
13$mail->port=25;
14$mail->From='booz@machin.com';
15$mail->AddAddress('booz@machin.net');
16$mail->AddReplyTo('booz@machin.net');   
17$mail->Subject='ceci n\'est pas un test';
18$mail->SMTPAuth = true;
19$mail->Username = "booz@machin.com";
20$mail->Password = "toto";
21$mail->AddStringAttachment("IMG/auton4.jpg", "Logo.jpg");
22
23// HTML body
24    $body  = "Hello <font size=\"4\">BoOz</font>, <p>";
25    $body .= "<i>Your</i> personal photograph to this message.<p>";
26    $body .= "Sincerely, <br>";
27    $body .= "PHPMailer List manager";
28
29    // Plain text body (for mail clients that cannot read HTML)
30    $text_body  = "Hello, \n\n";
31    $text_body .= "Your personal photograph to this message.\n\n";
32    $text_body .= "Sincerely, \n";
33    $text_body .= "PHPMailer List manager";
34
35    $mail->Body    = $body;
36    $mail->AltBody = $text_body;
37    $mail->AddAddress("cedric@bidule.com","Cedribox");
38    $mail->AddStringAttachment("IMG/siteon0", "YourPhoto.jpg");
39
40
41if(!$mail->Send()){ //Teste le return code de la fonction
42  echo $mail->ErrorInfo; //Affiche le message d'erreur (ATTENTION:voir section 7)
43}
44else{
45  echo 'Mail envoye avec succes';
46}
47
48$mail->SmtpClose();
49// Clear all addresses and attachments for next loop
50$mail->ClearAddresses();
51$mail->ClearAttachments();
52unset($mail);
53
54//envoi par mail();
55#$mail->Mailer   = "mail";
56
57//envoi format html seul
58#$mail->IsHTML();
59//envoi format texte seul
60#$mail->IsTEXT();
61
62?>
Note: See TracBrowser for help on using the repository browser.