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.
|
Can now send (hopefully) valid uplink requests to BBBS systems.
|
||||||
Removed some debug logging from un_attach, made one into a
|
Removed some debug logging from un_attach, made one into a
|
||||||
normal logmessage.
|
normal logmessage.
|
||||||
|
The postemail and scanemail functions are changed so that
|
||||||
|
Outlook email addresses are parsed so that we can reply via
|
||||||
|
smtp.
|
||||||
|
|
||||||
mbindex:
|
mbindex:
|
||||||
Fixed compiling pointlists where on the Boss line there is no
|
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)
|
int postemail(FILE *fp, char *MailFrom, char *MailTo)
|
||||||
{
|
{
|
||||||
char *temp, *p;
|
char *temp, *p, buf[4096];
|
||||||
char buf[4096];
|
int result = 1;
|
||||||
int result = 1;
|
faddr *fa;
|
||||||
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.
|
||||||
* If a user forgets the To: line at the start of the FTN
|
* We can't deliver this and create a loop if we pass this
|
||||||
* netmail, we end up here with a UUCP user with a local
|
* message to SMTP.
|
||||||
* address as the destination.
|
*/
|
||||||
* We can't deliver this and create a loop if we pass this
|
if ((fa = parsefaddr(MailTo))) {
|
||||||
* message to SMTP.
|
if (is_local(fa)) {
|
||||||
*/
|
WriteError("Destination is a local FTN address");
|
||||||
if ((fa = parsefaddr(MailTo))) {
|
email_bad++;
|
||||||
if (is_local(fa)) {
|
|
||||||
WriteError("Destination is a local FTN address");
|
|
||||||
email_bad++;
|
|
||||||
tidy_faddr(fa);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
tidy_faddr(fa);
|
tidy_faddr(fa);
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
tidy_faddr(fa);
|
||||||
|
}
|
||||||
|
|
||||||
if (smtp_connect() == -1) {
|
if (smtp_connect() == -1) {
|
||||||
WriteError("SMTP: connection refused");
|
WriteError("SMTP: connection refused");
|
||||||
email_bad++;
|
email_bad++;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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);
|
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)
|
void ExportEmail(unsigned long MsgNum)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p, *q, MailFrom[128], MailTo[128];
|
||||||
FILE *qp;
|
FILE *qp;
|
||||||
int retval, flags = 0, kludges = TRUE;
|
int retval, flags = 0, kludges = TRUE;
|
||||||
faddr *from, *too;
|
faddr *from, *too;
|
||||||
@ -1146,26 +1146,35 @@ void ExportEmail(unsigned long MsgNum)
|
|||||||
if (CFG.EmailMode != E_NOISP) {
|
if (CFG.EmailMode != E_NOISP) {
|
||||||
/*
|
/*
|
||||||
* Dialup or direct internet connection, send message via MTA.
|
* Dialup or direct internet connection, send message via MTA.
|
||||||
* First check if the From and To addresses contain spaces, if
|
* Reformat the addresses for SMTP.
|
||||||
* so everything after the space is removed.
|
|
||||||
*/
|
*/
|
||||||
p = Msg.From;
|
p = Msg.From;
|
||||||
while (*p) {
|
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
|
||||||
if (*p == ' ') {
|
q = strtok(p, "<");
|
||||||
*p = '\0';
|
q = strtok(NULL, ">");
|
||||||
break;
|
sprintf(MailFrom, "%s", q);
|
||||||
}
|
} else if (Msg.From[0] == ' ') {
|
||||||
p++;
|
q = strtok(p, " ");
|
||||||
|
q = strtok(NULL, " \n\r\t");
|
||||||
|
sprintf(MailFrom, "%s", q);
|
||||||
|
} else {
|
||||||
|
sprintf(MailFrom, "%s", Msg.From);
|
||||||
}
|
}
|
||||||
p = Msg.To;
|
|
||||||
while (*p) {
|
p = Msg.To;
|
||||||
if (*p == ' ') {
|
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
|
||||||
*p = '\0';
|
q = strtok(p, "<");
|
||||||
break;
|
q = strtok(NULL, ">");
|
||||||
}
|
sprintf(MailTo, "%s", q);
|
||||||
p++;
|
} 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 {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Message goes to UUCP gateway.
|
* Message goes to UUCP gateway.
|
||||||
|
@ -2448,6 +2448,7 @@ void CheckMail()
|
|||||||
* Only check the received status of the email. The mail
|
* Only check the received status of the email. The mail
|
||||||
* may not be direct addressed to this user (aliases database)
|
* may not be direct addressed to this user (aliases database)
|
||||||
* but if it is in his mailbox it is always for the user.
|
* 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) {
|
if (!Msg.Received) {
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user