Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $uniqueid = "";
- $username = "";
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception as PHPMailerException;
- require dirname(__FILE__) . '/phpmailer/src/Exception.php';
- require dirname(__FILE__) . '/phpmailer/src/PHPMailer.php';
- require dirname(__FILE__) . '/phpmailer/src/SMTP.php';
- $db = mysqli_connect('localhost', 'root', '', 'occupation');
- if (!$db) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $email=$_GET['email'];
- ***********here query in the data base but not valid if it exists********************
- $sql ="SELECT FROM users WHERE email='$email'";
- if (isset($_GET['email'])) {
- $message = "Salut! Bienvenue au site. \nvotre ID est : '$uniqueid'\n"
- . "votre nom d'utilisateur est : '$username'";
- $subject = 'Merci';
- // ========== SEND EMAIL TO USER ======================
- $mail = new PHPMailer(true);
- $smtp_credentials = [
- 'username' => 'email@gmail.com', // change to your gmail address
- 'password' => 'password' // change to your gmail password
- ];
- try {
- $mail->isSMTP();
- $mail->isHTML(true);
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->Username = $smtp_credentials['username'];
- $mail->Password = $smtp_credentials['password'];
- $mail->SMTPSecure = 'tls';
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 587;
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- // email context
- $mail->setFrom($smtp_credentials['username'], 'Mohamed Douhaji');
- *********************here you will leave in username because you have not received data from database**************************
- $mail->addAddress($email, $username);
- $mail->Subject = $subject;
- $mail->Body = $message;
- $mail->AltBody = strip_tags($message);
- // send email
- $mail->send();
- } catch (PHPMailerException $e) {
- die('Message could not be sent. ' . $mail->ErrorInfo);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement