// Include PHPMailer library require_once 'path/to/PHPMailer.php'; // Get form data $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; // Generate random activation code $activation_code = md5($username . time()); // Initialize PHPMailer object $mail = new PHPMailer; // Set SMTP settings $mail->isSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = 'tls'; $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->Username = 'your@gmail.com'; $mail->Password = 'your_password'; // Set mail content $mail->setFrom('your@gmail.com', 'Your Name'); $mail->addAddress($email, $username); $mail->isHTML(true); $mail->Subject = 'Account Activation'; $mail->Body = " Hello $username,In the above example, we have used the PHPMailer library to send an account activation email to the user after successful registration. The activation link contains a randomly generated code, which can be used to activate the user account when clicked. Overall, PHP offers various libraries and functions to make user registration in PHP applications easy and efficient. The choice of package/library depends on the specific requirements and use case of the application.
Thank you for registering on our website. Please click the following link to activate your account:
Activate
Best Regards,
Your Name "; // Send mail if (!$mail->send()) { echo 'Error: ' . $mail->ErrorInfo; } else { // Store user data in database // ... }