$Log$
+Revision 1.463 2000/02/18 05:10:50 ajc
+* Made the <.ASI> command a bit friendlier.
+* SMTP sender now pays attention to "smarthost" entries in the system's
+ Internet configuration, using them if one or more is present.
+
Revision 1.462 2000/02/17 05:27:39 ajc
* Got the "MAIL From:" command sending the correct data. (unnnhhhhnnhhhh...)
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
#include "citadel.h"
#include "domain.h"
#include "server.h"
+#include "tools.h"
+#include "internet_addressing.h"
+
+
+/*
+ * get_smarthosts() checks the Internet configuration for "smarthost"
+ * entries and returns them in the same format as getmx() does -- fill the
+ * buffer with a delimited list of hosts and return the number of hosts.
+ */
+int get_smarthosts(char *mxbuf) {
+ int config_lines;
+ int i;
+ char buf[256];
+ char host[256], type[256];
+ int total_smarthosts = 0;
+
+ if (inetcfg == NULL) return(0);
+ strcpy(mxbuf, "");
+
+ config_lines = num_tokens(inetcfg, '\n');
+ for (i=0; i<config_lines; ++i) {
+ extract_token(buf, inetcfg, i, '\n');
+ extract_token(host, buf, 0, '|');
+ extract_token(type, buf, 1, '|');
+
+ if (!strcasecmp(type, "smarthost")) {
+ strcat(mxbuf, host);
+ strcat(mxbuf, "|");
+ ++total_smarthosts;
+ }
+ }
+
+ return(total_smarthosts);
+}
+
+
-#define SMART_HOST "gatekeeper.wdcs.com"
/*
* sort_mxrecs()
unsigned char *startptr, *endptr, *ptr;
char expanded_buf[1024];
unsigned short pref, type;
- int n;
+ int n = 0;
HEADER *hp;
int qdcount;
struct mx *mxrecs = NULL;
int num_mxrecs = 0;
-
+
/* If we're configured to send all mail to a smart-host, then our
* job here is really easy.
*/
- if (0) { /* FIX */
- strcpy(mxbuf, SMART_HOST);
- return(1);
- }
+ n = get_smarthosts(mxbuf);
+ if (n > 0) return(n);
- /* No smart-host? Look up the best MX for a site.
+ /*
+ * No smart-host? Look up the best MX for a site.
*/
ret = res_query(
dest,
}
+/*
+ * support function for do_internet_configuration()
+ */
+void get_inet_rec_type(char *buf) {
+ int sel;
+
+ keyopt(" <1> localhost (Alias for this computer)\n");
+ keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
+ keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
+ sel = intprompt("Which one", 1, 1, 3);
+ switch(sel) {
+ case 1: strcpy(buf, "localhost");
+ return;
+ case 2: strcpy(buf, "gatewaydomain");
+ return;
+ case 3: strcpy(buf, "smarthost");
+ return;
+ }
+}
+
+
/*
* Internet mail configuration
*/
newprompt("Enter host name: ",
buf, 50);
strcat(buf, "|");
- newprompt("Enter record type: ",
- &buf[strlen(buf)], 20);
+ get_inet_rec_type(&buf[strlen(buf)]);
recs[num_recs-1] = strdup(buf);
break;
case 'd':