address.go 388 B

1234567891011121314151617181920212223
  1. package himinbjorg
  2. import (
  3. "fmt"
  4. "github.com/emersion/go-imap"
  5. )
  6. func MakeNameAddress(a *imap.Address, encode bool) string {
  7. personalName := ""
  8. if encode {
  9. fields := a.Format()
  10. personalName = fields[0].(string)
  11. } else {
  12. personalName = a.PersonalName
  13. }
  14. if personalName != "" {
  15. return fmt.Sprintf("%s <%s>", personalName, a.Address())
  16. } else {
  17. return a.Address()
  18. }
  19. }