Beispiel #1
0
func loginAction(c *cli.Context) {
	api := getAPI(c)
	var url string
	var version string
	var username string
	var password string
	fmt.Printf("URL: ")
	_, urlErr := fmt.Scanln(&url)
	if urlErr != nil {
		panic(urlErr)
	}
	fmt.Printf("Username: "******"Version (default: 1): ")
	_, verErr := fmt.Scanln(&version)
	if verErr != nil {
		version = "1"
	}
	userData, loginErr := api.Login(url, username, password)
	if loginErr != nil {
		LogMessage("Error logging in.  Please check username/password.", "r")
		os.Exit(1)
	}
	saveConfig(username, userData.ApiKey, url, version, c.GlobalString("config"))
	LogMessage("Login successful", "g")
}
func main() {
	m := &gophermail.Message{}
	m.SetFrom("Utiliz <*****@*****.**>")
	//m.AddTo("Kevin Manley <*****@*****.**>")
	m.AddTo("Tom Place <*****@*****.**>")
	m.Subject = "Test multi-part message with atch sent from Golang via sendgrid"
	m.HTMLBody = `
<html>
  <body>
    <h2>Test</h2>
	Did it work?
	<hr/>
	<table border="1">
	<tr>
	  <th>Col1</th><th>Col2</th>
	</tr>
	<tr>
	  <td>Foo</td><td>Bar</td>
	</tr>
	</table>
	<br/>
	<img src="https://cdn.scratch.mit.edu/static/site/projects/thumbnails/1095/8698.png"/>
  </body>
</html>
`
	m.Body = "This is the plain text body for those without an HTML capable email client"
	//fmt.Println(m.Bytes())
	atchname := "logo-resistor-400x400.png"
	data, _ := os.Open(atchname)
	atch := &gophermail.Attachment{Name: atchname,
		Data: data}
	m.Attachments = append(m.Attachments, *atch)

	pwd, _ := getpass.GetPass()

	a := smtp.PlainAuth("", "utiliz",
		pwd, "smtp.sendgrid.net")

	err := gophermail.SendMail("smtp.sendgrid.net:587", a, m)
	if err != nil {
		fmt.Println("err: ", err)
	} else {
		fmt.Println("ok")
	}

}
Beispiel #3
0
func authenticate() {
	var username, password string
	fmt.Println("Enter your GitHub account credentials.")

	fmt.Printf("Username: "******"%s", &username)
	password, _ = getpass.GetPass()
	fmt.Println()

	file, err := os.OpenFile(configFilePath(), os.O_CREATE|os.O_WRONLY, 0600)
	if err != nil {
		log.Fatal(err)
	}
	defer func() {
		file.Close()
	}()

	fmt.Fprintf(file, "%s\n", username)
	fmt.Fprintf(file, "%s\n", password)
}