EMAIL can now invoke POP65 and SMTP65, and they will invoke it in return

This commit is contained in:
Bobbi Webber-Manners 2020-07-15 19:45:25 -04:00
parent 1a1b499e43
commit c02af8d466
6 changed files with 56 additions and 19 deletions

View File

@ -42,6 +42,7 @@ pi
NODELETE
192.168.10.2
apple2.local
/IP65
/H1/DOCUMENTS/EMAIL
bobbi.8bit@gmail.com
```
@ -54,8 +55,9 @@ The lines are as follows, in order:
4) If this string is exactly `DELETE` then messages will be deleted from the POP3 server after downloading. Otherwise they are left on the server. `DELETE` is the normal setting, but `NODELETE` (or any other nonsense value) can be helpful for debugging, allowing the same messages to be downloaded from the POP3 server again and again.
5) IP address of the SMTP server for sending outgoing mail.
6) Domain name that is passed to the SMTP server on connection. The way my SMTP server (Postfix) is configured, it doesn't seem to care about this.
7) ProDOS path to the root of the email folder tree. Mailboxes will be created and managed under this root path.
8) Your email address. Used as the sender's address in outgoing messages.
7) ProDOS path of the directory where the email executables are installed.
8) ProDOS path to the root of the email folder tree. Mailboxes will be created and managed under this root path.
9) Your email address. Used as the sender's address in outgoing messages.
### Creating Directories

View File

@ -168,6 +168,7 @@ void readconfigfile(void) {
fscanf(fp, "%s", cfg_pop_delete);
fscanf(fp, "%s", cfg_smtp_server);
fscanf(fp, "%s", cfg_smtp_domain);
fscanf(fp, "%s", cfg_instdir);
fscanf(fp, "%s", cfg_emaildir);
fscanf(fp, "%s", cfg_emailaddr);
fclose(fp);
@ -1525,13 +1526,21 @@ void create_blank_outgoing() {
error(ERR_NONFATAL, filename);
}
/*
* Load EDIT.SYSTEM to $2000 and jump to it
* (This code is in language card space so it can't possibly be trashed)
*/
// Shove this up in the Language Card out of an abundance of caution
#pragma code-name (push, "LC")
void load_editor(void) {
exec("/IP65/EDIT.SYSTEM", NULL);
sprintf(filename, "%s/EDIT.SYSTEM", cfg_instdir);
exec(filename, NULL);
}
void load_pop65(void) {
sprintf(filename, "%s/POP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
void load_smtp65(void) {
sprintf(filename, "%s/SMTP65.SYSTEM", cfg_instdir);
exec(filename, "EMAIL");
}
#pragma code-name (pop)
@ -1682,8 +1691,14 @@ void keyboard_hdlr(void) {
reverse = 0;
switch_mailbox(curr_mbox);
break;
case 0x12: // Ctrl-R 'Receive messages from server'
load_pop65();
break;
case 0x13: // Ctrl-S 'Send queued messages'
load_smtp65();
break;
case '!': // Secret debug command!!!
load_editor();
load_pop65();
break;
case 'q':
case 'Q':

View File

@ -4,6 +4,7 @@ passwordgoeshere
NODELETE
192.168.10.2
apple2.local
/IP65/E
/IP65
/H1/EMAIL
bobbi.8bit@gmail.com

View File

@ -13,6 +13,7 @@ char cfg_pass[40]; // POP3 password
char cfg_pop_delete[40]; // If 'DELETE', delete message from POP3
char cfg_smtp_server[40]; // IP of SMTP server
char cfg_smtp_domain[40]; // Our domain
char cfg_instdir[80]; // ProDOS directory where apps are installed
char cfg_emaildir[80]; // ProDOS directory at root of email tree
char cfg_emailaddr[80]; // Our email address

View File

@ -37,6 +37,7 @@ static unsigned char buf[NETBUFSZ+1]; // One extra byte for null terminator
static char linebuf_pad[1]; // One byte of padding make it easier
static char linebuf[LINEBUFSZ];
uint8_t exec_email_on_exit = 0;
char filename[80];
int len;
FILE *fp;
@ -48,6 +49,10 @@ uint32_t filesize;
void confirm_exit(void) {
printf("\nPress any key ");
cgetc();
if (exec_email_on_exit) {
sprintf(filename, "%s/EMAIL.SYSTEM", cfg_instdir);
exec(filename, NULL);
}
exit(0);
}
@ -285,12 +290,12 @@ void expect(char *buf, char *s) {
}
/*
* Read parms from POP65.CFG
* Read parms from EMAIL.CFG
*/
void readconfigfile(void) {
fp = fopen("POP65.CFG", "r");
fp = fopen("EMAIL.CFG", "r");
if (!fp) {
puts("Can't open config file POP65.CFG");
puts("Can't open config file EMAIL.CFG");
error_exit();
}
fscanf(fp, "%s", cfg_server);
@ -299,6 +304,7 @@ void readconfigfile(void) {
fscanf(fp, "%s", cfg_pop_delete);
fscanf(fp, "%s", cfg_smtp_server);
fscanf(fp, "%s", cfg_smtp_domain);
fscanf(fp, "%s", cfg_instdir);
fscanf(fp, "%s", cfg_emaildir);
fclose(fp);
}
@ -469,18 +475,21 @@ void update_inbox(uint16_t nummsgs) {
write_next_email(nextemail);
}
void main(void) {
void main(int argc, char *argv[]) {
uint8_t eth_init = ETH_INIT_DEFAULT;
char sendbuf[80];
uint16_t msg, nummsgs;
uint32_t bytes;
if ((argc == 2) && (strcmp(argv[1], "EMAIL") == 0))
exec_email_on_exit = 1;
linebuf_pad[0] = 0;
videomode(VIDEOMODE_80COL);
printf("%c%s POP3%c\n", 0x0f, PROGNAME, 0x0e);
printf("\nReading POP65.CFG -");
printf("\nReading EMAIL.CFG -");
readconfigfile();
printf(" Ok");

View File

@ -37,6 +37,7 @@
static unsigned char buf[NETBUFSZ+1]; // One extra byte for null terminator
static char linebuf[LINEBUFSZ];
uint8_t exec_email_on_exit = 0;
char filename[80];
int len;
FILE *fp;
@ -48,6 +49,10 @@ uint32_t filesize;
void confirm_exit(void) {
printf("\nPress any key ");
cgetc();
if (exec_email_on_exit) {
sprintf(filename, "%s/EMAIL.SYSTEM", cfg_instdir);
exec(filename, NULL);
}
exit(0);
}
@ -286,12 +291,12 @@ uint8_t expect(char *buf, char *s) {
}
/*
* Read parms from POP65.CFG
* Read parms from EMAIL.CFG
*/
void readconfigfile(void) {
fp = fopen("POP65.CFG", "r");
fp = fopen("EMAIL.CFG", "r");
if (!fp) {
puts("Can't open config file POP65.CFG");
puts("Can't open config file EMAIL.CFG");
error_exit();
}
fscanf(fp, "%s", cfg_server);
@ -300,6 +305,7 @@ void readconfigfile(void) {
fscanf(fp, "%s", cfg_pop_delete);
fscanf(fp, "%s", cfg_smtp_server);
fscanf(fp, "%s", cfg_smtp_domain);
fscanf(fp, "%s", cfg_instdir);
fscanf(fp, "%s", cfg_emaildir);
fscanf(fp, "%s", cfg_emailaddr);
fclose(fp);
@ -471,7 +477,7 @@ void update_sent_mbox(char *name) {
write_next_email(nextemail);
}
void main(void) {
void main(int argc, char *argv[]) {
static char sendbuf[80], recipients[160];
uint8_t eth_init = ETH_INIT_DEFAULT;
uint8_t linecount;
@ -479,10 +485,13 @@ void main(void) {
struct dirent *d;
char *p, *q;
if ((argc == 2) && (strcmp(argv[1], "EMAIL") == 0))
exec_email_on_exit = 1;
videomode(VIDEOMODE_80COL);
printf("%c%s SMTP%c\n", 0x0f, PROGNAME, 0x0e);
printf("\nReading POP65.CFG -");
printf("\nReading EMAIL.CFG -");
readconfigfile();
printf(" Ok");