79706018

Date: 2025-07-18 10:12:57
Score: 0.5
Natty:
Report link
import random
import smtplib
from email.mime.text import MIMEText

# 1. Fungsi buat kode acak
def generate_verification_code(length=6):
    return ''.join(str(random.randint(0, 9)) for _ in range(length))

# 2. Buat kode
code = generate_verification_code()

# 3. Email tujuan dan isi
recipient_email = "[email protected]"
subject = "Kode Verifikasi Anda"
body = f"Kode verifikasi Anda adalah: {code}"

# 4. Buat email
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = "[email protected]"   # Ganti dengan email kamu
msg['To'] = recipient_email

# 5. Kirim via SMTP Gmail
try:
    smtp_server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
    smtp_server.login("[email protected]", "password_aplikasi_anda")  # Gunakan password aplikasi Gmail
    smtp_server.send_message(msg)
    smtp_server.quit()
    print(f"Kode berhasil dikirim ke {recipient_email}")
except Exception as e:
    print("Gagal mengirim email:", e)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Naasru