Standard library / net/mail

mail.Address.String()

Format a mailbox, encoding non-ASCII display names as needed. Do not treat formatting as deliverability validation. Expected stdout: 'café ada@example.invalid\n'.

Formal Syntax & Structure

go syntaxgo
func (a *Address) String() string

Return Value

string

Formatted mailbox address.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/mail")
func main() {  v := mail.Address{Name: "café", Address: "ada@example.invalid"}  a := must(mail.ParseAddress(v.String()))  fmt.Println(a.Name, a.Address)}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference