-
- /* 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;