// Generated by Lisette bindgen
// Source: net/smtp (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.11

import "go:crypto/tls"
import "go:io"
import "go:net"
import "go:net/textproto"

pub fn CRAMMD5Auth(username: string, secret: string) -> Auth

pub fn Dial(addr: string) -> Result<Ref<Client>, error>

pub fn NewClient(conn: net.Conn, host: string) -> Result<Ref<Client>, error>

pub fn PlainAuth(
  identity: string,
  username: string,
  password: string,
  host: string,
) -> Auth

/// SendMail connects to the server at addr, switches to TLS if
/// possible, authenticates with the optional mechanism a if possible,
/// and then sends an email from address from, to addresses to, with
/// message msg.
/// The addr must include a port, as in "mail.example.com:smtp".
/// 
/// The addresses in the to parameter are the SMTP RCPT addresses.
/// 
/// The msg parameter should be an RFC 822-style email with headers
/// first, a blank line, and then the message body. The lines of msg
/// should be CRLF terminated. The msg headers should usually include
/// fields such as "From", "To", "Subject", and "Cc".  Sending "Bcc"
/// messages is accomplished by including an email address in the to
/// parameter but not including it in the msg headers.
/// 
/// The SendMail function and the net/smtp package are low-level
/// mechanisms and provide no support for DKIM signing, MIME
/// attachments (see the mime/multipart package), or other mail
/// functionality. Higher-level packages exist outside of the standard
/// library.
pub fn SendMail(
  addr: string,
  a: Auth,
  from: string,
  to: Slice<string>,
  msg: Slice<uint8>,
) -> Result<(), error>

/// Auth is implemented by an SMTP authentication mechanism.
pub interface Auth {
  fn Next(fromServer: Slice<uint8>, more: bool) -> Result<Slice<uint8>, error>
  fn Start(server: Ref<ServerInfo>) -> Result<(string, Slice<uint8>), error>
}

/// A Client represents a client connection to an SMTP server.
pub struct Client {
  pub Text: Option<Ref<textproto.Conn>>,
}

/// ServerInfo records information about an SMTP server.
pub struct ServerInfo {
  pub Name: string,
  pub TLS: bool,
  pub Auth: Slice<string>,
}

impl Client {
  /// Auth authenticates a client using the provided authentication mechanism.
  /// A failed authentication closes the connection.
  /// Only servers that advertise the AUTH extension support this function.
  fn Auth(self: Ref<Client>, a: Auth) -> Result<(), error>

  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<Client>) -> Result<(), error>

  /// Data issues a DATA command to the server and returns a writer that
  /// can be used to write the mail headers and body. The caller should
  /// close the writer before calling any more methods on c. A call to
  /// Data must be preceded by one or more calls to [Client.Rcpt].
  fn Data(self: Ref<Client>) -> Result<io.WriteCloser, error>

  /// Extension reports whether an extension is support by the server.
  /// The extension name is case-insensitive. If the extension is supported,
  /// Extension also returns a string that contains any parameters the
  /// server specifies for the extension.
  fn Extension(self: Ref<Client>, ext: string) -> (bool, string)

  /// Hello sends a HELO or EHLO to the server as the given host name.
  /// Calling this method is only necessary if the client needs control
  /// over the host name used. The client will introduce itself as "localhost"
  /// automatically otherwise. If Hello is called, it must be called before
  /// any of the other methods.
  fn Hello(self: Ref<Client>, localName: string) -> Result<(), error>

  /// Mail issues a MAIL command to the server using the provided email address.
  /// If the server supports the 8BITMIME extension, Mail adds the BODY=8BITMIME
  /// parameter. If the server supports the SMTPUTF8 extension, Mail adds the
  /// SMTPUTF8 parameter.
  /// This initiates a mail transaction and is followed by one or more [Client.Rcpt] calls.
  fn Mail(self: Ref<Client>, from: string) -> Result<(), error>

  /// Noop sends the NOOP command to the server. It does nothing but check
  /// that the connection to the server is okay.
  fn Noop(self: Ref<Client>) -> Result<(), error>

  /// Quit sends the QUIT command and closes the connection to the server.
  fn Quit(self: Ref<Client>) -> Result<(), error>

  /// Rcpt issues a RCPT command to the server using the provided email address.
  /// A call to Rcpt must be preceded by a call to [Client.Mail] and may be followed by
  /// a [Client.Data] call or another Rcpt call.
  fn Rcpt(self: Ref<Client>, to: string) -> Result<(), error>

  /// Reset sends the RSET command to the server, aborting the current mail
  /// transaction.
  fn Reset(self: Ref<Client>) -> Result<(), error>

  /// StartTLS sends the STARTTLS command and encrypts all further communication.
  /// Only servers that advertise the STARTTLS extension support this function.
  fn StartTLS(self: Ref<Client>, config: Ref<tls.Config>) -> Result<(), error>

  /// TLSConnectionState returns the client's TLS connection state.
  /// The return values are their zero values if [Client.StartTLS] did
  /// not succeed.
  fn TLSConnectionState(self: Ref<Client>) -> Option<tls.ConnectionState>

  /// Verify checks the validity of an email address on the server.
  /// If Verify returns nil, the address is valid. A non-nil return
  /// does not necessarily indicate an invalid address. Many servers
  /// will not verify addresses for security reasons.
  fn Verify(self: Ref<Client>, addr: string) -> Result<(), error>
}
