POP65/SMTP65: Allow port number to be changed in email.cfg

This commit is contained in:
Bobbi Webber-Manners 2020-09-03 16:43:33 -04:00
parent 53cc860b89
commit fdd5daa61f
3 changed files with 49 additions and 33 deletions

View File

@ -1,8 +1,8 @@
192.168.10.2 192.168.10.2:110
pi pi
passwordgoeshere passwordgoeshere
NODELETE NODELETE
192.168.10.2 192.168.10.2:25
apple2.local apple2.local
/IP65 /IP65
/DATA/EMAIL /DATA/EMAIL

View File

@ -42,6 +42,7 @@ char filename[80];
int len; int len;
FILE *fp; FILE *fp;
uint32_t filesize; uint32_t filesize;
uint16_t pop_port;
/* /*
* Keypress before quit * Keypress before quit
@ -293,6 +294,7 @@ void expect(char *buf, char *s) {
* Read parms from EMAIL.CFG * Read parms from EMAIL.CFG
*/ */
void readconfigfile(void) { void readconfigfile(void) {
char *colon;
fp = fopen("EMAIL.CFG", "r"); fp = fopen("EMAIL.CFG", "r");
if (!fp) { if (!fp) {
puts("Can't open config file EMAIL.CFG"); puts("Can't open config file EMAIL.CFG");
@ -307,6 +309,12 @@ void readconfigfile(void) {
fscanf(fp, "%s", cfg_instdir); fscanf(fp, "%s", cfg_instdir);
fscanf(fp, "%s", cfg_emaildir); fscanf(fp, "%s", cfg_emaildir);
fclose(fp); fclose(fp);
colon = strchr(cfg_smtp_server, ':');
if (!colon)
pop_port = 110;
else
pop_port = atoi(colon + 1);
} }
/* /*
@ -515,7 +523,7 @@ void main(int argc, char *argv[]) {
printf("Ok\nConnecting to %s - ", cfg_server); printf("Ok\nConnecting to %s - ", cfg_server);
if (!w5100_connect(parse_dotted_quad(cfg_server), 110)) { if (!w5100_connect(parse_dotted_quad(cfg_server), pop_port)) {
printf("Fail\n"); printf("Fail\n");
error_exit(); error_exit();
} }

View File

@ -42,6 +42,7 @@ char filename[80];
int len; int len;
FILE *fp; FILE *fp;
uint32_t filesize; uint32_t filesize;
uint16_t smtp_port;
/* /*
* Keypress before quit * Keypress before quit
@ -329,6 +330,7 @@ uint8_t expect(char *buf, char *s) {
* Read parms from EMAIL.CFG * Read parms from EMAIL.CFG
*/ */
void readconfigfile(void) { void readconfigfile(void) {
char *colon;
fp = fopen("EMAIL.CFG", "r"); fp = fopen("EMAIL.CFG", "r");
if (!fp) { if (!fp) {
puts("Can't open config file EMAIL.CFG"); puts("Can't open config file EMAIL.CFG");
@ -344,6 +346,12 @@ void readconfigfile(void) {
fscanf(fp, "%s", cfg_emaildir); fscanf(fp, "%s", cfg_emaildir);
fscanf(fp, "%s", cfg_emailaddr); fscanf(fp, "%s", cfg_emailaddr);
fclose(fp); fclose(fp);
colon = strchr(cfg_smtp_server, ':');
if (!colon)
smtp_port = 25;
else
smtp_port = atoi(colon + 1);
} }
/* /*
@ -521,7 +529,7 @@ void main(int argc, char *argv[]) {
printf("Ok\nConnecting to %s - ", cfg_smtp_server); printf("Ok\nConnecting to %s - ", cfg_smtp_server);
if (!w5100_connect(parse_dotted_quad(cfg_smtp_server), 25)) { if (!w5100_connect(parse_dotted_quad(cfg_smtp_server), smtp_port)) {
printf("Fail\n"); printf("Fail\n");
error_exit(); error_exit();
} }