Commit de Marco : Correction de bug PHPMailer
This commit is contained in:
@@ -17,17 +17,19 @@ class Contact extends CI_Controller {
|
||||
}
|
||||
|
||||
public function index() {
|
||||
// Vérifiez si le formulaire de contact a été soumis
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('nous-contacter');
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
public function send_message() {
|
||||
if ($this->input->post()) {
|
||||
// Récupérez les données du formulaire
|
||||
$name = $this->input->post('name');
|
||||
$email = $this->input->post('email');
|
||||
$message = $this->input->post('message');
|
||||
|
||||
// Envoi d'email avec PHPMailer
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
//Server settings
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.gmail.com';
|
||||
$mail->SMTPAuth = true;
|
||||
@@ -53,9 +55,51 @@ class Contact extends CI_Controller {
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
} else {
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('accueil');
|
||||
$this->load->view('layout/footer_dark');
|
||||
redirect('contact');
|
||||
}
|
||||
}
|
||||
|
||||
public function send_detailed_message() {
|
||||
if ($this->input->post()) {
|
||||
$name = $this->input->post('name');
|
||||
$email = $this->input->post('email');
|
||||
$message = $this->input->post('message');
|
||||
$attachment = $_FILES['attachment'];
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.gmail.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'onzeur.contact@gmail.com';
|
||||
$mail->Password = 'ofoi hjpo isxf azdk';
|
||||
$mail->SMTPSecure = 'tls';
|
||||
$mail->Port = 587;
|
||||
|
||||
$mail->setFrom($email, $name);
|
||||
$mail->addAddress('onzeur.contact@gmail.com');
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = 'Formulaire de contact Onzeur - ' . $name;
|
||||
$mail->Body = $message;
|
||||
|
||||
// Gérer la pièce jointe
|
||||
if (!empty($attachment['tmp_name'])) {
|
||||
$mail->addAttachment($attachment['tmp_name'], $attachment['name']);
|
||||
}
|
||||
|
||||
$mail->send();
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('confirmation_mail.php');
|
||||
$this->load->view('layout/footer_dark');
|
||||
} catch (Exception $e) {
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('erreur_mail.php');
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
} else {
|
||||
redirect('nous-contacter');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user