func (state *RuntimeState) SuccessRequestemail(requesteduser string, usersEmail []string,
	groupname, remoteAddr, userAgent string) error {
	// Connect to the remote SMTP server.
	c, err := smtpClient(state.Config.Base.SMTPserver)
	if err != nil {
		log.Println(err)
		return err
	}
	defer c.Close()
	// Set the sender and recipient.
	c.Mail(state.Config.Base.SmtpSenderAddress)
	for _, recipient := range usersEmail {
		//c.Rcpt("recipient@example.net")
		c.Rcpt(recipient)
	}
	// Send the email body.
	wc, err := c.Data()
	if err != nil {
		log.Println(err)
		return err
	}
	defer wc.Close()
	//get browser details
	ua := user_agent.New(userAgent)
	uaName, _ := ua.Browser()

	mailData := mailAttributes{
		RequestedUser: requesteduser,
		Groupname:     groupname,
		Hostname:      state.Config.Base.Hostname,
		Browser:       uaName,
		OS:            ua.OS(),
		OtherUser:     ""}

	templ, err := texttemplate.New("mailbody").Parse(requestAccessMailTemplateText)
	if err != nil {
		log.Fatal(err)
	}
	err = templ.Execute(wc, mailData)
	if err != nil {
		log.Fatal(err)
	}

	return nil
}
//send email for requesting access to a group
send email for requesting access to a group
// send email for requesting access to a group
func (state *RuntimeState) SuccessRequestemail(requesteduser string, usersEmail []string,
	groupname, remoteAddr, userAgent string) error {
	c, err := smtpClient(state.Config.Base.SMTPserver)
	if err != nil {
		log.Println(err)
		return err
	}
	defer c.Close()
	c.Mail(state.Config.Base.SmtpSenderAddress)
	for _, recipient := range usersEmail {
		c.Rcpt(recipient)
	}
	wc, err := c.Data()
	if err != nil {
		log.Println(err)
		return err
	}
	defer wc.Close()
	ua := user_agent.New(userAgent)
	uaName, _ := ua.Browser()
	mailData := mailAttributes{
		RequestedUser: requesteduser,
		Groupname:     groupname,
		Hostname:      state.Config.Base.Hostname,
		Browser:       uaName,
		OS:            ua.OS(),
		OtherUser:     ""}
	templ, err := texttemplate.New("mailbody").Parse(requestAccessMailTemplateText)
	if err != nil {
		log.Fatal(err)
	}
	err = templ.Execute(wc, mailData)
	if err != nil {
		log.Fatal(err)
	}
	return nil
}
func ( state * RuntimeState ) SuccessRequestemail ( requesteduser string , usersEmail [ ] string , groupname , remoteAddr , userAgent string ) error { c , err := smtpClient ( state . Config . Base . SMTPserver ) if err != nil { log . Println ( err ) return err } defer c . Close ( ) c . Mail ( state . Config . Base . SmtpSenderAddress ) for _ , recipient := range usersEmail { c . Rcpt ( recipient ) } wc , err := c . Data ( ) if err != nil { log . Println ( err ) return err } defer wc . Close ( ) ua := user_agent . New ( userAgent ) uaName , _ := ua . Browser ( ) mailData := mailAttributes { RequestedUser : requesteduser , Groupname : groupname , Hostname : state . Config . Base . Hostname , Browser : uaName , OS : ua . OS ( ) , OtherUser : " " } templ , err := texttemplate . New ( " " ) . Parse ( requestAccessMailTemplateText ) if err != nil { log . Fatal ( err ) } err = templ . Execute ( wc , mailData ) if err != nil { log . Fatal ( err ) } return nil }
send email for requesting access to a group
send email for requesting access to a group
// Connect to the remote SMTP server. // Set the sender and recipient. //c.Rcpt("recipient@example.net") // Send the email body. //get browser details