+void get_one_mx_host_name_done(void *Ctx,
+ int status,
+ int timeouts,
+ struct hostent *hostent)
+{
+ SmtpOutMsg *SendMsg = Ctx;
+ if ((status == ARES_SUCCESS) && (hostent != NULL) ) {
+
+ SendMsg->IO.HEnt = hostent;
+ InitEventIO(&SendMsg->IO, SendMsg,
+ SMTP_C_DispatchReadDone,
+ SMTP_C_DispatchWriteDone,
+ SMTP_C_Terminate,
+ SMTP_C_Timeout,
+ SMTP_C_ConnFail,
+ SMTP_C_ReadServerStatus,
+ 1);
+
+ }
+}
+
+const char *DefaultMXPort = "25";
+void connect_one_smtpsrv(SmtpOutMsg *SendMsg)
+{
+ //char *endpart;
+ //char buf[SIZ];
+
+ SendMsg->mx_port = DefaultMXPort;
+
+/* TODO: Relay!
+ *SendMsg->mx_user = '\0';
+ *SendMsg->mx_pass = '\0';
+ if (num_tokens(buf, '@') > 1) {
+ strcpy (SendMsg->mx_user, buf);
+ endpart = strrchr(SendMsg->mx_user, '@');
+ *endpart = '\0';
+ strcpy (SendMsg->mx_host, endpart + 1);
+ endpart = strrchr(SendMsg->mx_user, ':');
+ if (endpart != NULL) {
+ strcpy(SendMsg->mx_pass, endpart+1);
+ *endpart = '\0';
+ }
+
+ endpart = strrchr(SendMsg->mx_host, ':');
+ if (endpart != 0){
+ *endpart = '\0';
+ strcpy(SendMsg->mx_port, endpart + 1);
+ }
+ }
+ else
+*/
+ SendMsg->mx_host = SendMsg->CurrMX->host;
+ SendMsg->CurrMX = SendMsg->CurrMX->next;
+
+ CtdlLogPrintf(CTDL_DEBUG,
+ "SMTP client[%ld]: connecting to %s : %s ...\n",
+ SendMsg->n,
+ SendMsg->mx_host,
+ SendMsg->mx_port);
+
+ ares_gethostbyname(SendMsg->IO.DNSChannel,
+ SendMsg->mx_host,
+ AF_INET6, /* it falls back to ipv4 in doubt... */
+ get_one_mx_host_name_done,
+ &SendMsg->IO);
+/*
+ if (!QueueQuery(ns_t_a,
+ SendMsg->mx_host,
+ &SendMsg->IO,
+ connect_one_smtpsrv_xamine_result))
+ {
+ /// TODO: abort
+ }
+*/
+}
+