Advertisement
Guest User

PHPMailer

a guest
Jul 18th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. if($_SERVER["REQUEST_METHOD"] == "POST"){
  2.  
  3.             //require('lib/phpmailer/class.smtp.php');
  4.             // require('lib/phpmailer/class.phpmailer.php');
  5.             //require('lib/phpmailer/PHPMailerAutoload.php');
  6.  
  7.        
  8.  
  9.             $mail = new PHPMailer();
  10.  
  11.             $errors = validator::check($form["struct"], $args);
  12.             $to = 'social.media.wedo@gmail.com';
  13.             $subject = $_POST['name']." ".$_POST['firstname'];
  14.             $message = $_POST['content'];
  15.             $headers  = 'MIME-Version: 1.0' . "\r\n";
  16.             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  17.             var_dump($_POST);
  18.             mail($to, $subject, $message, $headers);
  19.        
  20.  
  21.        
  22.             // $mail->isSMTP();    
  23.  
  24.  
  25.  
  26.             $mail->IsMail(); // active SMTP
  27.             $mail->SMTPDebug = 3;  // debogage: 1 = Erreurs et messages, 2 = messages seulement
  28.    
  29.             $mail->SMTPSecure = 'tls'; // Gmail REQUIERT Le transfert securise
  30.  
  31.             $mail->Host = 'smtp.gmail.com';
  32.            
  33.  
  34.             $mail->SMTPAuth = true;
  35.             $mail->Username = 'social.media.wedo@gmail.com';
  36.             $mail->Password = 'secret';
  37.             $mail->Port = 587; // Par défaut
  38.              
  39.             // Expéditeur
  40.             $mail->SetFrom($_POST['email'], 'kevin');
  41.             // Destinataire
  42.             $mail->AddAddress($to, $_POST['firstname']);
  43.             // Objet
  44.             $mail->Subject = $_POST['name'];
  45.              
  46.             // Votre message
  47.             $mail->MsgHTML($_POST['content']);
  48.            
  49.             // Envoi du mail avec gestion des erreurs
  50.             if(!$mail->Send()) {
  51.               echo 'Erreur : ' . $mail->ErrorInfo;
  52.             } else {
  53.               echo 'Message envoyé !';
  54.             }
  55.        
  56.         $mail->isSMTP();                                      // Set mailer to use SMTP
  57.         $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  58.         $mail->SMTPAuth = true;                               // Enable SMTP authentication
  59.         $mail->Username = 'social.media.wedo@gmail.com';                 // SMTP username
  60.         $mail->Password = 'secret';                           // SMTP password
  61.         $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  62.         $mail->Port = 587;                                    // TCP port to connect to
  63.          
  64.         $mail->setFrom('social.media.wedo@gmail.com', 'kevin');
  65.         $mail->addAddress('rajekevin@hotmail.fr');     // Add a recipient
  66.         $mail->addReplyTo('social.media.wedo@gmail.com', 'Information');
  67.          
  68.         $mail->isHTML(true);                                  // Set email format to HTML
  69.          
  70.         $mail->Subject = 'hello';
  71.         $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  72.         $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  73.          
  74.         if(!$mail->send()) {
  75.             echo 'Message could not be sent.';
  76.             echo 'Mailer Error: ' . $mail->ErrorInfo;
  77.         } else {
  78.             echo 'Message has been sent';
  79.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement