Hi,

Sorry if this is done before, but I wanted to support DSN under cygwin.
sendmail isnt the easiest thing to compile under cygwin, and a bit
overkill, so I've tweaked ssmtp to take the DSN flags in a sendmailish
style.

Regards,

Luke
--- ssmtp-2.38.7-3/ssmtp.c      Thu Jun  7 13:54:20 2001
+++ ssmtp.c     Sun Jan  6 18:42:28 2002
@@ -61,6 +61,8 @@
 char *specifiedFrom = NULL;    /* Content of the From: field if specified
                                 with the -f option */
 char *specifiedName = NULL;    /* Same for -F option */
+char *dsnReturn = NULL;                /* When to return DSN */
+char *dsnHowMuch = NULL;       /* Headers or full */
 char *fullName = NULL;         /* Sending user's full name */
 char *Root = "postmaster";     /* Person to send root's mail to. */
 struct passwd *Sender = NULL;  /* The person sending the mail. */
@@ -993,6 +995,7 @@
              continue;
            case 'R':
              if (!argv[i][j+1]) {      /* amount of the message to be returned */
+           dsnHowMuch = strdup(argv[i+1]);
                add++;
                goto exit;
              }
@@ -1027,8 +1030,11 @@
            case 'M':           /* Use specified message-id. */
              goto exit;
            case 'N':           /* dsn options */
-             add++;
-             goto exit;
+             if (!argv[i][j+1]) {      /* amount of the message to be returned */
+           dsnReturn = strdup(argv[i+1]);
+               add++;
+               goto exit;
+             }
            case 'n':           /* No aliasing. */
              continue;
            case 'o':
@@ -1206,7 +1212,7 @@
   /* if user supplied username and password, then try ELHO */
   /* do not really know if this is required or not...      */
   
-  if (authUsername)
+  if (authUsername || dsnReturn)
     putToSmtp (fd, "EHLO %s", HostName);
   else
     putToSmtp (fd, "HELO %s", HostName);
@@ -1241,11 +1247,21 @@
   /* Send "MAIL FROM:" line */
   if (msgFromLine && FromLineOverride)
     {
+           if (dsnReturn && dsnHowMuch) {
+      putToSmtp (fd, "MAIL FROM:<%s> RET=%s", stripFromLine(msgFromLine),dsnHowMuch);
+       } else {
       putToSmtp (fd, "MAIL FROM:<%s>", stripFromLine(msgFromLine));
+       }
       free(msgFromLine);
     }
-  else
+  else {
+           if (dsnReturn && dsnHowMuch) {
+    putToSmtp (fd, "MAIL FROM:<%s> RET=%s", (specifiedFrom!=NULL) ? specifiedFrom : 
+stripFromLine(fromLine), dsnHowMuch);
+       } else {
     putToSmtp (fd, "MAIL FROM:<%s>", (specifiedFrom!=NULL) ? specifiedFrom : 
stripFromLine(fromLine));
+           }
+      free(msgFromLine);
+  }
 
   (void) alarm ((unsigned) MEDWAIT);
   if (getOkFromSmtp (fd, buffer) == NO)
@@ -1271,7 +1287,11 @@
       i = 0;
       do
        {
+           if (dsnReturn) {
+         putToSmtp (fd, "RCPT TO:<%s> NOTIFY=%s", properRecipient 
+(recipients[i]),dsnReturn);
+           } else {
          putToSmtp (fd, "RCPT TO:<%s>", properRecipient (recipients[i]));
+           }
          (void) alarm ((unsigned) MEDWAIT);
          if (getOkFromSmtp (fd, buffer) == NO)
            {
@@ -1290,7 +1310,11 @@
            {
              /* RFC822 Address  -> "foo@bar" */
               parseaddr(p, buffer, sizeof(buffer));
+           if (dsnReturn) {
+             putToSmtp (fd, "RCPT TO:<%s> NOTIFY=%s", properRecipient 
+(buffer),dsnReturn);
+           } else {
              putToSmtp (fd, "RCPT TO:<%s>", properRecipient (buffer));
+           }
              (void) alarm ((unsigned) MEDWAIT);
              if (getOkFromSmtp (fd, buffer) == NO)
                {

Reply via email to