+ParsedURL *LoadRelayUrls(OneQueItem *MyQItem,
+ char *Author,
+ char *Address)
+{
+ int nRelays = 0;
+ ParsedURL *RelayUrls = NULL;
+ char mxbuf[SIZ];
+ ParsedURL **Url = &MyQItem->URL;
+
+ nRelays = get_hosts(mxbuf, "fallbackhost");
+ if (nRelays > 0) {
+ StrBuf *All;
+ StrBuf *One;
+ const char *Pos = NULL;
+ All = NewStrBufPlain(mxbuf, -1);
+ One = NewStrBufPlain(NULL, StrLength(All) + 1);
+
+ while ((Pos != StrBufNOTNULL) &&
+ ((Pos == NULL) ||
+ !IsEmptyStr(Pos)))
+ {
+ StrBufExtract_NextToken(One, All, &Pos, '|');
+ if (!ParseURL(Url, One, DefaultMXPort)) {
+ SMTPC_syslog(LOG_DEBUG,
+ "Failed to parse: %s\n",
+ ChrPtr(One));
+ }
+ else {
+ (*Url)->IsRelay = 1;
+ MyQItem->HaveRelay = 1;
+ }
+ }
+ FreeStrBuf(&All);
+ FreeStrBuf(&One);
+ }
+ nRelays = get_hosts(mxbuf, "smarthost");
+ if (nRelays > 0) {
+ char *User;
+ StrBuf *All;
+ StrBuf *One;
+ const char *Pos = NULL;
+ All = NewStrBufPlain(mxbuf, -1);
+ One = NewStrBufPlain(NULL, StrLength(All) + 1);
+
+ while ((Pos != StrBufNOTNULL) &&
+ ((Pos == NULL) ||
+ !IsEmptyStr(Pos)))
+ {
+ StrBufExtract_NextToken(One, All, &Pos, '|');
+ User = strchr(ChrPtr(One), ' ');
+ if (User != NULL) {
+ if (!strcmp(User + 1, Author) ||
+ !strcmp(User + 1, Address))
+ StrBufCutAt(One, 0, User);
+ else
+ continue;
+
+ }
+ if (!ParseURL(Url, One, DefaultMXPort)) {
+ SMTPC_syslog(LOG_DEBUG,
+ "Failed to parse: %s\n",
+ ChrPtr(One));
+ }
+ else {
+ ///if (!Url->IsIP)) // todo dupe me fork ipv6
+ (*Url)->IsRelay = 1;
+ MyQItem->HaveRelay = 1;
+ }
+ }
+ FreeStrBuf(&All);
+ FreeStrBuf(&One);
+ }
+ return RelayUrls;
+}