-/**
- * this one has to have the context for loading the message via the redirect buffer...
- */
-StrBuf *smtp_load_msg(OneQueItem *MyQItem)
-{
- CitContext *CCC=CC;
- StrBuf *SendMsg;
-
- CCC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
- CtdlOutputMsg(MyQItem->MessageID, MT_RFC822, HEADERS_ALL, 0, 1, NULL, (ESC_DOT|SUPPRESS_ENV_TO) );
- SendMsg = CCC->redirect_buffer;
- CCC->redirect_buffer = NULL;
- if ((StrLength(SendMsg) > 0) &&
- ChrPtr(SendMsg)[StrLength(SendMsg) - 1] != '\n') {
- CtdlLogPrintf(CTDL_WARNING,
- "SMTP client[%ld]: Possible problem: message did not "
- "correctly terminate. (expecting 0x10, got 0x%02x)\n",
- MsgCount, //yes uncool, but best choice here...
- ChrPtr(SendMsg)[StrLength(SendMsg) - 1] );
- StrBufAppendBufPlain(SendMsg, HKEY("\r\n"), 0);
- }
- return SendMsg;
-}
-
-
-int smtp_resolve_recipients(SmtpOutMsg *SendMsg)
-{
- const char *ptr;
- char buf[1024];
- int scan_done;
- int lp, rp;
- int i;
-
- /* Parse out the host portion of the recipient address */
- process_rfc822_addr(ChrPtr(SendMsg->MyQEntry->Recipient),
- SendMsg->user,
- SendMsg->node,
- SendMsg->name);
-
- CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n",
- SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
- /* If no envelope_from is supplied, extract one from the message */
- if ( (SendMsg->envelope_from == NULL) ||
- (IsEmptyStr(SendMsg->envelope_from)) ) {
- SendMsg->mailfrom[0] = '\0';
- scan_done = 0;
- ptr = ChrPtr(SendMsg->msgtext);
- do {
- if (ptr = cmemreadline(ptr, buf, sizeof buf), *ptr == 0) {
- scan_done = 1;
- }
- if (!strncasecmp(buf, "From:", 5)) {
- safestrncpy(SendMsg->mailfrom, &buf[5], sizeof SendMsg->mailfrom);
- striplt(SendMsg->mailfrom);
- for (i=0; SendMsg->mailfrom[i]; ++i) {
- if (!isprint(SendMsg->mailfrom[i])) {
- strcpy(&SendMsg->mailfrom[i], &SendMsg->mailfrom[i+1]);
- i=0;
- }
- }
-
- /* Strip out parenthesized names */
- lp = (-1);
- rp = (-1);
- for (i=0; !IsEmptyStr(SendMsg->mailfrom + i); ++i) {
- if (SendMsg->mailfrom[i] == '(') lp = i;
- if (SendMsg->mailfrom[i] == ')') rp = i;
- }
- if ((lp>0)&&(rp>lp)) {
- strcpy(&SendMsg->mailfrom[lp-1], &SendMsg->mailfrom[rp+1]);
- }
-
- /* Prefer brokketized names */
- lp = (-1);
- rp = (-1);
- for (i=0; !IsEmptyStr(SendMsg->mailfrom + i); ++i) {
- if (SendMsg->mailfrom[i] == '<') lp = i;
- if (SendMsg->mailfrom[i] == '>') rp = i;
- }
- if ( (lp>=0) && (rp>lp) ) {
- SendMsg->mailfrom[rp] = 0;
- memmove(SendMsg->mailfrom,
- &SendMsg->mailfrom[lp + 1],
- rp - lp);
- }
-
- scan_done = 1;
- }
- } while (scan_done == 0);
- if (IsEmptyStr(SendMsg->mailfrom)) strcpy(SendMsg->mailfrom, "someone@somewhere.org");
- stripallbut(SendMsg->mailfrom, '<', '>');
- SendMsg->envelope_from = SendMsg->mailfrom;
- }