- substdio ssto;
- substdio ssfrom;
- unsigned long code;
- int flaganyrecipok;
- int i;
-
- substdio_fdbuf(&ssto,timeoutwrite,TIMEOUTWRITE(timeout,fd),smtptobuf,sizeof(smtptobuf));
- substdio_fdbuf(&ssfrom,timeoutread,TIMEOUTREAD(timeout,fd),smtpfrombuf,sizeof(smtpfrombuf));
-
- if (smtpcode(&ssfrom) != 220)
- {
- out("ZConnected to "); outhost(); out(" but greeting failed.\n");
- quit(&ssto,&ssfrom);
- }
-
- if (substdio_puts(&ssto,"HELO ") == -1) writeerr();
- if (substdio_put(&ssto,helohost.s,helohost.len) == -1) writeerr();
- if (substdio_puts(&ssto,"\r\n") == -1) writeerr();
- if (substdio_flush(&ssto) == -1) writeerr();
-
- if (smtpcode(&ssfrom) != 250)
- {
- out("ZConnected to "); outhost(); out(" but my name was rejected.\n");
- quit(&ssto,&ssfrom);
- }
-
- if (substdio_puts(&ssto,"MAIL FROM:<") == -1) writeerr();
- if (substdio_put(&ssto,sender.s,sender.len) == -1) writeerr();
- if (substdio_puts(&ssto,">\r\n") == -1) writeerr();
- if (substdio_flush(&ssto) == -1) writeerr();
-
- code = smtpcode(&ssfrom);
- if (code >= 500)
- {
- out("DConnected to "); outhost(); out(" but sender was rejected.\n");
- quit(&ssto,&ssfrom);
- }
- if (code >= 400)
- {
- out("ZConnected to "); outhost(); out(" but sender was rejected.\n");
- quit(&ssto,&ssfrom);
- }
-
- flaganyrecipok = 0;
- for (i = 0;i < reciplist.len;++i)
- {
- if (substdio_puts(&ssto,"RCPT TO:<") == -1) writeerr();
- if (substdio_put(&ssto,reciplist.sa[i].s,reciplist.sa[i].len) == -1) writeerr();
- if (substdio_puts(&ssto,">\r\n") == -1) writeerr();
- if (substdio_flush(&ssto) == -1) writeerr();
-
- code = smtpcode(&ssfrom);
- if (code == 421)
- {
- out("ZConnected to "); outhost(); out(" but connection died.\n");
- quit(&ssto,&ssfrom);
- }
- if (code >= 500)
- {
- out("h"); outhost(); out(" does not like recipient.\n");
- outsmtptext(); zero();
+ unsigned long code;
+ int flagbother;
+ int i;
+
+ if (smtpcode() != 220) quit("ZConnected to "," but greeting failed");
+
+ substdio_puts(&smtpto,"HELO ");
+ substdio_put(&smtpto,helohost.s,helohost.len);
+ substdio_puts(&smtpto,"\r\n");
+ substdio_flush(&smtpto);
+ if (smtpcode() != 250) quit("ZConnected to "," but my name was rejected");
+
+ substdio_puts(&smtpto,"MAIL FROM:<");
+ substdio_put(&smtpto,sender.s,sender.len);
+ substdio_puts(&smtpto,">\r\n");
+ substdio_flush(&smtpto);
+ code = smtpcode();
+ if (code >= 500) quit("DConnected to "," but sender was rejected");
+ if (code >= 400) quit("ZConnected to "," but sender was rejected");
+
+ flagbother = 0;
+ for (i = 0;i < reciplist.len;++i) {
+ substdio_puts(&smtpto,"RCPT TO:<");
+ substdio_put(&smtpto,reciplist.sa[i].s,reciplist.sa[i].len);
+ substdio_puts(&smtpto,">\r\n");
+ substdio_flush(&smtpto);
+ code = smtpcode();
+ if (code >= 500) {
+ out("h"); outhost(); out(" does not like recipient.\n");
+ outsmtptext(); zero();