Jump to content

email verifier


Recommended Posts

# Check if input file exists
If Not FileExists("emails.txt") Then
    MsgBox(0, "Error", "Input file 'emails.txt' does not exist.")
    Exit
EndIf


# Read input file
$file = FileOpen("emails.txt", 0)

# Check if output files exists
If Not FileExists("valid_emails.txt") Then
    FileCreate("valid_emails.txt")
EndIf
If Not FileExists("invalid_emails.txt") Then
    FileCreate("invalid_emails.txt")
EndIf

# Check if output files are open
If Not FileIsOpen($valid_file) Then
    FileOpen("valid_emails.txt", 2)
EndIf
If Not FileIsOpen($invalid_file) Then
    FileOpen("invalid_emails.txt", 2)
EndIf




# Open output files
$valid_file = FileOpen("valid_emails.txt", 2)
$invalid_file = FileOpen("invalid_emails.txt", 2)


    ; Define SMTP server, username, and password
    $smtp_server = "smtp.gmail.com"
    $username = "account"
    $password = "password"
    $port = "587"

    $valid_count = 0
    $invalid_count = 0

    While 1
        $email = FileReadLine($file)
        If @error Then ExitLoop

        ; Check for valid email format
        If StringRegExp($email, "[^@]+@[^@]+\.[^@]+") Then
            ; Connect to SMTP server and check if email exists
            $smtp = ObjCreate("WinHttp.WinHttpRequest.5.1")
            $smtp.Open("HEAD", "smtp://" & $username & ":" & $password & "@" & $smtp_server & ":" & $port, False)
            $smtp.Send()

            ; Check if connection to SMTP server was successful
            If $smtp.Status = 200 Then
                $valid_count += 1
                FileWriteLine($valid_file, $email)
            Else
                ; Check if credentials are incorrect
                If $smtp.Status = 401 Then
                    MsgBox(0, "Error", "Incorrect username or password")
                Else
                    ; Check if email does not exist on server
                    If $smtp.Status = 550 Then
                        FileWriteLine($invalid_file, $email & " - Email does not exist on server")
                        $invalid_count += 1
                    Else
                        ; Handle other errors
                        MsgBox(0, "Error", "Error connecting to SMTP server: " & $smtp.Status)
                    EndIf
                EndIf
            EndIf

        Else
            FileWriteLine($invalid_file, $email & " - Invalid email format")
            $invalid_count += 1
        EndIf
    WEnd

    FileClose($file)
    FileClose($valid_file)
    FileClose($invalid_file)

# Display results
    $valid_count = FileCountLines("valid_emails.txt")
    $invalid_count = FileCountLines("invalid_emails.txt")
MsgBox(0, "Verification complete", "Valid emails found: " & $valid_count & ", Invalid emails found: " & $invalid_count)

Else
    ; Display error message if input file does not exist
    MsgBox(0, "Error", "Input file does not exist

i have this script that tries to verify emails if they`re valid or not through smtp protocol

i get an error saying the input file doesnt exist when it exists

 

510638924_Screenshot2023-01-28073942.png.34365d3986570d38479697e1273ba91d.png

 

invalid_emails.txt

valid_emails.txt

emails.txt

Link to comment
Share on other sites

5 minutes ago, Undisputed said:

i get an error saying the input file doesnt exist when it exists

You've misinterpreted the error message. If you take another look, you will see that the error is on line 92 and the actual reason is "unterminated string". There are multiple issues with the last line of your script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...