nim-lang / smtp

SMTP client implementation, adapted from the Nim standard library
MIT License
10 stars 5 forks source link

IPv6 support #6

Open mildred opened 11 months ago

mildred commented 11 months ago

When the server is IPv6 only, connect fails:

Error: unhandled exception: Additional info: Name or service not known
Async traceback:
  /home/mildred/Projets/sqlemail.nim/src/submit_email.nim(112) submit_email
  /home/mildred/Projets/sqlemail.nim/src/submit_email.nim(54) send (Async)
  /home/mildred/.nimble/pkgs2/smtp-0.1.0-df9380a905e6f2f9f4228474077ca15f2ccbde29/smtp.nim(254) connect
  /home/mildred/.choosenim/toolchains/nim-2.0.0/lib/pure/net.nim(2055) connect
  /home/mildred/.choosenim/toolchains/nim-2.0.0/lib/pure/nativesockets.nim(311) getAddrInfo
  /home/mildred/.choosenim/toolchains/nim-2.0.0/lib/std/oserrors.nim(92) raiseOSError
Exception message: Additional info: Name or service not known

edit: sorry, it might be my server down instead

mildred commented 10 months ago

Problem seems to be in asyncdispatch where getaddrinfo is called with AF_INET instead of AF_UNSPEC

mildred commented 10 months ago

Reopening issue. See https://github.com/nim-lang/Nim/issues/22442 and forum thread. The problem is that the smtp package uses newSocket and then connect whereas to have an IPv6 compatible library one should use dial which performs the address lookup and then created the socket using the correct address family depending on if the address is IPv4 or IPv6.