A VTU airtime web application for purchasing data, airtime, and bill payment.
- This script handles the OTP generation and stores it in the database.
- After storing the OTP, it calls
sendMail()
to send an email.
- This script uses PHPMailer to send the email.
- It receives the email body and sends the email via SMTP.
- The front-end (JavaScript) sends an AJAX request to
send-otp.php
when the user enters an email.
✔️ Extracts the user's email from $_POST
.
✔️ Validates the email format.
✔️ Generates a random 6-digit OTP.
✔️ Stores the OTP in the database (otp_codes
table).
✔️ Prepares the email body (HTML format).
✔️ Calls sendMail()
function to send the email.
✔️ Returns a JSON response to the front-end.
✔️ Uses PHPMailer to send an email via SMTP.
✔️ Configures SMTP settings (host
, username
, password
, encryption
, port
).
✔️ Sends the email to the user with the OTP.
✔️ Logs errors if the email fails.
send-otp.php
generates and stores OTP ⏩ callssendMail()
fromsendMail.php
.sendMail.php
takes care of actually sending the email.
💡 send-otp.php
is like the manager, sendMail.php
is like the delivery guy. 🚀
1️⃣ User enters email & clicks "Send OTP"
2️⃣ send-otp.php
generates OTP & stores it
3️⃣ Calls sendMail($email, $subject, $body)
4️⃣ sendMail.php
sends the email via SMTP
5️⃣ User receives OTP email 🎉
Let me know if you need more clarification! 🚀