Fixes for Outlook emails
This commit is contained in:
parent
2921392683
commit
ff1b44f0e4
@ -22,6 +22,9 @@ v0.61.4 11-Aug-2004
|
||||
Can now send (hopefully) valid uplink requests to BBBS systems.
|
||||
Removed some debug logging from un_attach, made one into a
|
||||
normal logmessage.
|
||||
The postemail and scanemail functions are changed so that
|
||||
Outlook email addresses are parsed so that we can reply via
|
||||
smtp.
|
||||
|
||||
mbindex:
|
||||
Fixed compiling pointlists where on the Boss line there is no
|
||||
|
@ -56,90 +56,97 @@ extern int email_bad; /* Bad netmails */
|
||||
*/
|
||||
int postemail(FILE *fp, char *MailFrom, char *MailTo)
|
||||
{
|
||||
char *temp, *p;
|
||||
char buf[4096];
|
||||
int result = 1;
|
||||
faddr *fa;
|
||||
char *temp, *p, buf[4096];
|
||||
int result = 1;
|
||||
faddr *fa;
|
||||
parsedaddr rfcaddr;
|
||||
|
||||
rewind(fp);
|
||||
Syslog('+', "SMTP: posting email from \"%s\" to \"%s\"", MailFrom, MailTo);
|
||||
rewind(fp);
|
||||
Syslog('+', "SMTP: posting email from \"%s\" to \"%s\"", MailFrom, MailTo);
|
||||
|
||||
/*
|
||||
* If a user forgets the To: line at the start of the FTN
|
||||
* netmail, we end up here with a UUCP user with a local
|
||||
* address as the destination.
|
||||
* We can't deliver this and create a loop if we pass this
|
||||
* message to SMTP.
|
||||
*/
|
||||
if ((fa = parsefaddr(MailTo))) {
|
||||
if (is_local(fa)) {
|
||||
WriteError("Destination is a local FTN address");
|
||||
email_bad++;
|
||||
tidy_faddr(fa);
|
||||
return 2;
|
||||
}
|
||||
/*
|
||||
* If a user forgets the To: line at the start of the FTN
|
||||
* netmail, we end up here with a UUCP user with a local
|
||||
* address as the destination.
|
||||
* We can't deliver this and create a loop if we pass this
|
||||
* message to SMTP.
|
||||
*/
|
||||
if ((fa = parsefaddr(MailTo))) {
|
||||
if (is_local(fa)) {
|
||||
WriteError("Destination is a local FTN address");
|
||||
email_bad++;
|
||||
tidy_faddr(fa);
|
||||
return 2;
|
||||
}
|
||||
tidy_faddr(fa);
|
||||
}
|
||||
|
||||
if (smtp_connect() == -1) {
|
||||
WriteError("SMTP: connection refused");
|
||||
email_bad++;
|
||||
return 2;
|
||||
}
|
||||
if (smtp_connect() == -1) {
|
||||
WriteError("SMTP: connection refused");
|
||||
email_bad++;
|
||||
return 2;
|
||||
}
|
||||
|
||||
temp = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
||||
sprintf(temp, "MAIL FROM:<%s>\r\n", MailFrom);
|
||||
if (smtp_cmd(temp, 250)) {
|
||||
WriteError("SMTP: refused FROM <%s>", MailFrom);
|
||||
email_bad++;
|
||||
free(temp);
|
||||
return 2;
|
||||
}
|
||||
|
||||
sprintf(temp, "RCPT TO:<%s>\r\n", MailTo);
|
||||
if (smtp_cmd(temp, 250)) {
|
||||
WriteError("SMTP: refused TO <%s>", MailTo);
|
||||
email_bad++;
|
||||
free(temp);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (smtp_cmd((char *)"DATA\r\n", 354)) {
|
||||
WriteError("SMTP refused DATA mode");
|
||||
email_bad++;
|
||||
free(temp);
|
||||
return 2;
|
||||
}
|
||||
|
||||
while ((fgets(buf, sizeof(buf)-2, fp)) != NULL) {
|
||||
if (strncmp(buf, ".\r\n", 3)) {
|
||||
p = buf+strlen(buf)-1;
|
||||
if (*p == '\n') {
|
||||
*p++ = '\r';
|
||||
*p++ = '\n';
|
||||
*p = '\0';
|
||||
}
|
||||
smtp_send(buf);
|
||||
} else {
|
||||
sprintf(temp, " .\r\n");
|
||||
smtp_send(temp);
|
||||
}
|
||||
}
|
||||
|
||||
email_in++;
|
||||
if (smtp_cmd((char *)".\r\n", 250) == 0) {
|
||||
Syslog('+', "SMTP: Message accepted");
|
||||
result = 0;
|
||||
email_imp++;
|
||||
} else {
|
||||
WriteError("SMTP: refused message");
|
||||
email_bad++;
|
||||
}
|
||||
temp = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
||||
|
||||
rfcaddr = parserfcaddr(MailFrom);
|
||||
sprintf(temp, "MAIL FROM:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||
Syslog('m', "%s", printable(temp, 0));
|
||||
if (smtp_cmd(temp, 250)) {
|
||||
WriteError("SMTP: refused FROM <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||
email_bad++;
|
||||
free(temp);
|
||||
smtp_close();
|
||||
return 2;
|
||||
}
|
||||
tidyrfcaddr(rfcaddr);
|
||||
|
||||
return result;
|
||||
rfcaddr = parserfcaddr(MailTo);
|
||||
sprintf(temp, "RCPT TO:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||
Syslog('m', "%s", printable(temp, 0));
|
||||
if (smtp_cmd(temp, 250)) {
|
||||
WriteError("SMTP: refused TO <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||
email_bad++;
|
||||
free(temp);
|
||||
return 2;
|
||||
}
|
||||
tidyrfcaddr(rfcaddr);
|
||||
|
||||
if (smtp_cmd((char *)"DATA\r\n", 354)) {
|
||||
WriteError("SMTP refused DATA mode");
|
||||
email_bad++;
|
||||
free(temp);
|
||||
return 2;
|
||||
}
|
||||
|
||||
while ((fgets(buf, sizeof(buf)-2, fp)) != NULL) {
|
||||
if (strncmp(buf, ".\r\n", 3)) {
|
||||
p = buf+strlen(buf)-1;
|
||||
if (*p == '\n') {
|
||||
*p++ = '\r';
|
||||
*p++ = '\n';
|
||||
*p = '\0';
|
||||
}
|
||||
smtp_send(buf);
|
||||
} else {
|
||||
sprintf(temp, " .\r\n");
|
||||
smtp_send(temp);
|
||||
}
|
||||
}
|
||||
|
||||
email_in++;
|
||||
if (smtp_cmd((char *)".\r\n", 250) == 0) {
|
||||
Syslog('+', "SMTP: Message accepted");
|
||||
result = 0;
|
||||
email_imp++;
|
||||
} else {
|
||||
WriteError("SMTP: refused message");
|
||||
email_bad++;
|
||||
}
|
||||
|
||||
free(temp);
|
||||
smtp_close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ void ExportNet(unsigned long MsgNum, int UUCPgate)
|
||||
*/
|
||||
void ExportEmail(unsigned long MsgNum)
|
||||
{
|
||||
char *p;
|
||||
char *p, *q, MailFrom[128], MailTo[128];
|
||||
FILE *qp;
|
||||
int retval, flags = 0, kludges = TRUE;
|
||||
faddr *from, *too;
|
||||
@ -1146,26 +1146,35 @@ void ExportEmail(unsigned long MsgNum)
|
||||
if (CFG.EmailMode != E_NOISP) {
|
||||
/*
|
||||
* Dialup or direct internet connection, send message via MTA.
|
||||
* First check if the From and To addresses contain spaces, if
|
||||
* so everything after the space is removed.
|
||||
* Reformat the addresses for SMTP.
|
||||
*/
|
||||
p = Msg.From;
|
||||
while (*p) {
|
||||
if (*p == ' ') {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
|
||||
q = strtok(p, "<");
|
||||
q = strtok(NULL, ">");
|
||||
sprintf(MailFrom, "%s", q);
|
||||
} else if (Msg.From[0] == ' ') {
|
||||
q = strtok(p, " ");
|
||||
q = strtok(NULL, " \n\r\t");
|
||||
sprintf(MailFrom, "%s", q);
|
||||
} else {
|
||||
sprintf(MailFrom, "%s", Msg.From);
|
||||
}
|
||||
p = Msg.To;
|
||||
while (*p) {
|
||||
if (*p == ' ') {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
|
||||
p = Msg.To;
|
||||
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
|
||||
q = strtok(p, "<");
|
||||
q = strtok(NULL, ">");
|
||||
sprintf(MailTo, "%s", q);
|
||||
} else if (Msg.To[0] == ' ') {
|
||||
q = strtok(p, " ");
|
||||
q = strtok(NULL, " \n\r\t");
|
||||
sprintf(MailTo, "%s", q);
|
||||
} else {
|
||||
sprintf(MailTo, "%s", Msg.To);
|
||||
}
|
||||
retval = postemail(qp, Msg.From, Msg.To);
|
||||
|
||||
retval = postemail(qp, MailFrom, MailTo);
|
||||
} else {
|
||||
/*
|
||||
* Message goes to UUCP gateway.
|
||||
|
@ -2448,6 +2448,7 @@ void CheckMail()
|
||||
* Only check the received status of the email. The mail
|
||||
* may not be direct addressed to this user (aliases database)
|
||||
* but if it is in his mailbox it is always for the user.
|
||||
* FIXME: mail writte by the user is shown as new too.
|
||||
*/
|
||||
if (!Msg.Received) {
|
||||
/*
|
||||
|
Reference in New Issue
Block a user