Re: using '[al]pine' with OpenSMTP

2017-03-10 Thread Sunil Nimmagadda

Gilles Chehade  writes:

>> > Turns out it's a bit more than compat getopt(), we do accept and ignore
>> > those flags however.
>> >
>> > With 'sendmail -bs' MUA expects STMP dialog over stdin/stdout, which
>> > means, MUA will wait for the greeting on stdout while smtpctl waits for
>> > text on stdin and they are now deadlocked.
>> >
>> > The following diff bridges the enqueuer fd and stdout/stdin by writing
>> > output from fd to stdout and commands from stdin to fd.
>> >
>> > I can send mails with apline now without any config modifications and
>> > also enqueue via plain 'sendmail -bs'.
>> >
>> > Tests and comments welcome.
>> 
>> Revised diff. Ignore rest of '-b' options instead of returning an error.
>> 
>
> I really dislike this but I understand there's not much you can
> do to achieve it differently :-/
>
> one comment inline

Revised diff to move exit() out of the function.

>
> did you get a feedback from the original poster ?

Not yet.

diff --git a/smtpd/enqueue.c b/smtpd/enqueue.c
index 3fd7fbd6..c7c008d0 100644
--- a/smtpd/enqueue.c
+++ b/smtpd/enqueue.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +47,7 @@ extern struct imsgbuf *ibuf;
 
 void usage(void);
 static void build_from(char *, struct passwd *);
+static void handle_bs(void);
 static int parse_message(FILE *, int, int, FILE *);
 static void parse_addr(char *, size_t, int);
 static void parse_addr_terminal(int);
@@ -171,6 +173,7 @@ enqueue(int argc, char *argv[], FILE *ofp)
FILE*fp = NULL, *fout;
size_t   sz = 0, envid_sz = 0;
ssize_t  len;
+   int  bs_flag = 0;
int  fd;
char sfn[] = "/tmp/smtpd.XX";
char*line;
@@ -216,10 +219,13 @@ enqueue(int argc, char *argv[], FILE *ofp)
case 'V':
msg.dsn_envid = optarg;
break;
+   case 'b':
+   if (strcmp(optarg, "s") == 0)
+   bs_flag = 1;
+   break;
/* all remaining: ignored, sendmail compat */
case 'A':
case 'B':
-   case 'b':
case 'E':
case 'e':
case 'i':
@@ -240,6 +246,11 @@ enqueue(int argc, char *argv[], FILE *ofp)
argc -= optind;
argv += optind;
 
+   if (bs_flag) {
+   handle_bs();
+   exit(EX_OK);
+   }
+
if (getmailname(host, sizeof(host)) == -1)
errx(EX_NOHOST, "getmailname");
if (no_getlogin) {
@@ -458,6 +469,54 @@ fail:
exit(EX_SOFTWARE);
 }
 
+/*
+ * sendmail -bs requires STMP dialog over stdin/stdout.
+ * Bridge stdin/stdout with enqueuer fd.
+ */
+static void
+handle_bs(void)
+{
+   charbuf[LINE_MAX];
+   struct pollfd   pfd[2];
+   nfds_t  nfds;
+   size_t  i;
+   ssize_t nr;
+   int fd, nready, outfd;
+
+   if (!srv_connected())
+   errx(EX_UNAVAILABLE, "Server offline");
+
+   if ((fd = open_connection()) == -1)
+   errx(EX_UNAVAILABLE, "server too busy");
+
+   pfd[0].fd = STDIN_FILENO;
+   pfd[1].fd = fd;
+   pfd[0].events = pfd[1].events = POLLIN;
+   nfds = 2;
+   while ((nready = poll(pfd, nfds, INFTIM))) {
+   if (nready == -1)
+   err(1, "poll");
+
+   for (i = 0; i < nfds; i++) {
+   if (pfd[i].revents & (POLLERR|POLLNVAL))
+   errx(1, "bsd fd %d", pfd[i].fd);
+
+   if ((pfd[i].revents & (POLLIN|POLLHUP))) {
+   nr = read(pfd[i].fd, buf, sizeof buf);
+   if (nr == -1)
+   err(1, "read");
+   else if (nr == 0)
+   return;
+
+   outfd = pfd[i].fd == STDIN_FILENO ?
+   fd : STDOUT_FILENO;
+   if (write(outfd, buf, nr) == -1)
+   err(1, "write");
+   }
+   }
+   }
+}
+
 static int
 get_responses(FILE *fin, int n)
 {

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: using '[al]pine' with OpenSMTP

2017-03-07 Thread Sunil Nimmagadda

Sunil Nimmagadda <su...@nimmagadda.net> writes:

> Gilles Chehade <gil...@poolp.org> writes:
>
>> On Fri, Jan 06, 2017 at 08:20:05AM +0100, Antoine Jacoutot wrote:
>>> On Fri, Jan 06, 2017 at 02:35:46PM +1100, Damian McGuckin wrote:
>>> >
>>> > Does the FAQ need a section of tweaks for email clients?
>>> >
>>> > I tried to use 'alpine' on OpenBSD 6.0 with the standard SMTPD therein.
>>> >
>>> > A pkg_add'ed 'alpine' just sits there trying and trying until you go into
>>> >
>>> >   Main-Menu -> Setup -> Config
>>> >
>>> > and change the SMTP server to 'localhost'. I have never had to do that
>>> > in my life with 'alpine' on any other system that has used sendmail or
>>> > postfix.
>>> >
>>> > How many other email clients need tweaking for OpenSMTPD?
>>>
>>> It's probably due to the default sendmail flags used by alpine :
>>> smtp_msa_flags="-bs -odb -oem"
>>>
>>
>> ok, it is indeed due to these flags, OP should open a bug report on our
>> tracker and one of us will add compat to the enqueuer so it doesn't
>> choke on these.
>>
>>
>>> I'll have a look at the port today, there's a configure option to change the
>>> defaults.
>>>
>>
>> that would make it work out of the box on openbsd but still, we should
>> have the compat getopt() imo
>
> Turns out it's a bit more than compat getopt(), we do accept and ignore
> those flags however.
>
> With 'sendmail -bs' MUA expects STMP dialog over stdin/stdout, which
> means, MUA will wait for the greeting on stdout while smtpctl waits for
> text on stdin and they are now deadlocked.
>
> The following diff bridges the enqueuer fd and stdout/stdin by writing
> output from fd to stdout and commands from stdin to fd.
>
> I can send mails with apline now without any config modifications and
> also enqueue via plain 'sendmail -bs'.
>
> Tests and comments welcome.

Revised diff. Ignore rest of '-b' options instead of returning an error.

diff --git a/smtpd/enqueue.c b/smtpd/enqueue.c
index 3fd7fbd6..036a97c7 100644
--- a/smtpd/enqueue.c
+++ b/smtpd/enqueue.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +47,7 @@ extern struct imsgbuf *ibuf;

 void usage(void);
 static void build_from(char *, struct passwd *);
+static void handle_bs(void);
 static int parse_message(FILE *, int, int, FILE *);
 static void parse_addr(char *, size_t, int);
 static void parse_addr_terminal(int);
@@ -171,6 +173,7 @@ enqueue(int argc, char *argv[], FILE *ofp)
FILE*fp = NULL, *fout;
size_t   sz = 0, envid_sz = 0;
ssize_t  len;
+   int  bs_flag = 0;
int  fd;
char sfn[] = "/tmp/smtpd.XX";
char*line;
@@ -216,10 +219,13 @@ enqueue(int argc, char *argv[], FILE *ofp)
case 'V':
msg.dsn_envid = optarg;
break;
+   case 'b':
+   if (strcmp(optarg, "s") == 0)
+   bs_flag = 1;
+   break;
/* all remaining: ignored, sendmail compat */
case 'A':
case 'B':
-   case 'b':
case 'E':
case 'e':
case 'i':
@@ -240,6 +246,9 @@ enqueue(int argc, char *argv[], FILE *ofp)
argc -= optind;
argv += optind;

+   if (bs_flag)
+   handle_bs();
+
if (getmailname(host, sizeof(host)) == -1)
errx(EX_NOHOST, "getmailname");
if (no_getlogin) {
@@ -458,6 +467,57 @@ fail:
exit(EX_SOFTWARE);
 }

+/*
+ * sendmail -bs requires STMP dialog over stdin/stdout.
+ * Bridge stdin/stdout with enqueuer fd.
+ */
+static void
+handle_bs(void)
+{
+   charbuf[LINE_MAX];
+   struct pollfd   pfd[2];
+   nfds_t  nfds;
+   size_t  i;
+   ssize_t nr;
+   int fd, nready, outfd;
+
+   if (!srv_connected())
+   errx(EX_UNAVAILABLE, "Server offline");
+
+   if ((fd = open_connection()) == -1)
+   errx(EX_UNAVAILABLE, "server too busy");
+
+   pfd[0].fd = STDIN_FILENO;
+   pfd[1].fd = fd;
+   pfd[0].events = pfd[1].events = POLLIN;
+   nfds = 2;
+   while ((nready = poll(pfd, nfds, INFTIM))) {
+   if (nready == -1)
+   err(1, "poll");
+
+   for (i = 0; i < nfds; i++) {
+   if (p

Re: Recommended method for blasting the queue clean- can smtpctl be used?

2016-02-23 Thread Sunil Nimmagadda
> Can someone please commit Sunil's patch below to the main code base when  
> they get a chance?

This was committed the same day as I shared the diff on list...

commit 376147cc2686eca13e1ade1d121be2c5074c178b
Author: Sunil Nimmagadda <su...@nimmagadda.net>
Date:   Thu Jul 2 19:38:07 2015 +0530

Let "resume envelope", "pause envelope" and "remove" subcommands
accept "all" as a valid argument.

> 
> Removing all the spammer's bogus email destinations from my queue one at a  
> time is painful.
> 
> 
> On Thu, 02 Jul 2015 01:44:10 -0700, Sunil Nimmagadda  
> <su...@nimmagadda.net> wrote:
> 
> > As far I can see, the smtpctl is capable of...
> > smtpctl remove all
> > smtpctl resume envelope all
> > smtpctl pause envelope all
> >
> > just like...
> > smtpctl schedule all
> >
> > but a cmd_install of the "all" variant is missing.  This diff works
> > for me, could you try...
> >
> > diff --git a/smtpd/smtpctl.8 b/smtpd/smtpctl.8
> > index fa7a661..9369234 100644
> > --- a/smtpd/smtpctl.8
> > +++ b/smtpd/smtpctl.8
> > @@ -99,6 +99,8 @@ Generated bounces.
> >  .It Cm pause envelope Ar envelope-id | message-id
> >  Temporarily suspend scheduling for the envelope with the given ID,
> >  or all envelopes with the given message ID.
> > +.It Cm pause envelope all
> > +Temporarily suspend scheduling all the envelopes.
> >  .It Cm pause mda
> >  Temporarily stop deliveries to local users.
> >  .It Cm pause mta
> > @@ -119,9 +121,13 @@ imsg, to profile cost of event handlers
> >  .El
> >  .It Cm remove Ar envelope-id | message-id
> >  Remove a single envelope, or all envelopes with the same message ID.
> > +.It Cm remove all
> > +Remove all envelopes.
> >  .It Cm resume envelope Ar envelope-id | message-id
> >  Resume scheduling for the envelope with the given ID,
> >  or all envelopes with the given message ID.
> > +.It Cm resume envelope all
> > +Resume scheduling all the envelopes.
> >  .It Cm resume mda
> >  Resume deliveries to local users.
> >  .It Cm resume mta
> > diff --git a/smtpd/smtpctl.c b/smtpd/smtpctl.c
> > index e45a0a0..fa9642e 100644
> > --- a/smtpd/smtpctl.c
> > +++ b/smtpd/smtpctl.c
> > @@ -990,14 +990,17 @@ main(int argc, char **argv)
> > cmd_install("monitor",  do_monitor);
> > cmd_install("pause envelope ",   do_pause_envelope);
> > cmd_install("pause envelope ",   do_pause_envelope);
> > +   cmd_install("pause envelope all",   do_pause_envelope);
> > cmd_install("pause mda",do_pause_mda);
> > cmd_install("pause mta",do_pause_mta);
> > cmd_install("pause smtp",   do_pause_smtp);
> > cmd_install("profile ",do_profile);
> > cmd_install("remove ",   do_remove);
> > cmd_install("remove ",   do_remove);
> > +   cmd_install("remove all",   do_remove);
> > cmd_install("resume envelope ",  do_resume_envelope);
> > cmd_install("resume envelope ",  do_resume_envelope);
> > +   cmd_install("resume envelope all",  do_resume_envelope);
> > cmd_install("resume mda",   do_resume_mda);
> > cmd_install("resume mta",   do_resume_mta);
> > cmd_install("resume route ",   do_resume_route);
> >
> 
> 
> -- 
> Using Opera'smail client: http://www.opera.com/mail/
> 
> -- 
> You received this mail because you are subscribed to misc@opensmtpd.org
> To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org
> 

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: n00b question

2015-10-07 Thread Sunil Nimmagadda
> On Tue, Oct 06, 2015 at 13:38:31 -0400, Bryan C. Everly wrote:
> > I have two servers up and running and would like to know how to clean
> > out the queue on them.  I have a lot of test messages stuck there from
> > early attempts to get the configuration right.
> > 
> > Is there an option to do this?  I read the manpages and didn't see
> > anything.  If it's as simple as deleting some files out of a
> > directory, I'm fine doing that - I just couldn't find the right
> > directory.
> 
> When you're sure you want to get rid of every message in the queue you can us
e
> this one-liner (maybe overly complicated):
>  
> smtpctl show queue | awk -F \| '{ print "smtpctl remove "$1 }' |sh
> 
> Afaik there is no build in way to clean out the whole queue. 

There will be a...
# smtpctl remove all
in the future release. It's already in -current on github.

--
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: smtpd crash if .forward file exists

2015-03-31 Thread Sunil Nimmagadda
On Tue, Mar 31, 2015 at 04:50:45PM +0200, K. Peter wrote:
 Hi,
 
 I got a buffer overflow if a .forward file exists in the user home dir. All
 mailusers are defined in a userbase table. The mailfolders are located on a
 NAS and mounted via nfs. Running smtpd -dv gives:
 
 smtp-in: New session 0b5b409e8634b93c from host smtp.aldox.de [local]
 *** buffer overflow detected ***: smtpd: [priv] terminated
 === Backtrace: =
 /lib64/libc.so.6(+0x73d6f)[0x7f93fc3c9d6f]
 /lib64/libc.so.6(__fortify_fail+0x37)[0x7f93fc44eb67]

Did you compile with -D_FORTIFY_SOURCE? There were known false
positives with fortify and smtpd on linux. Packages on some linux
variants now ship with fortify disabled.

https://bugs.archlinux.org/task/38124
https://launchpad.net/ubuntu/+source/opensmtpd/+changelog

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: Best way to relay mail to a server with intermittent connectivity

2015-01-27 Thread Sunil Nimmagadda
On Tue, Jan 27, 2015 at 08:47:24PM -0800, Seth wrote:
 On Tue, 27 Jan 2015 20:18:04 -0800, Edgar Pettijohn
 ed...@pettijohn-web.com wrote:
 Still need to solve the problem of scheduling that big morning dump.
 
 Of email.
 
 cron
 
 That's not really going to work because the power-up time could vary between
 2-4 hours. The mail needs to flow as soon as possible after powering on the
 local server. What would be ideal is for the relaying server to probe the
 local server every five minutes. As soon as an active SMTP port is
 discovered on the local server, the relay sends all queued emails.

I was wondering what if your local server is the primary MX and
then your public server a backup MX. That way, whenever your local
server is online the mails end up directly in it and your backup
server automatically checks for primary server availability and
routes accumulated mails once the primary MX is up.


-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: smtpd: mail stuck in queue

2014-11-27 Thread Sunil Nimmagadda
 Hi,

 I noticed a box of mine having had a misconfigured mail relay, resulting 
 in lots of mail queuing up. Now, after fixing the configuration, new 
 mail are properly sent.

 However, it seems the invalid 'mta-relay' setting, as seen in the 
 envelopes of the queued mail does not get revised while issuing 'smtpctl 
 schedule ...'. Thus, the old mail stays in the queue.

 Any pointers on how to proceed is appreciated, possibly including 
 cluesticks as of why the observed behaviour might be the proper one.

 /Alexander

smtpctl schedule doesn't modify the contents of the queued envelopes.
A new smtpctl subcommand to rematch ruleset was proposed sometime
ago...  https://github.com/OpenSMTPD/OpenSMTPD/issues/237

Manually editing the envelopes already queued in /var/spool/smtpd/queue
and rescheduling should fix the issue. (Decompress and/or decrypt the
queue if needed.)

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: DSN problems

2014-06-18 Thread Sunil Nimmagadda
 On 16 Jun 2014, at 14:12, Sunil Nimmagadda wrote:

  From misc+bounces-888-sunil=nimmagadda@opensmtpd.org Mon Jun 16
  01:00:56 2014
  From: Ricardson Williams ricardsonwilli...@gmail.com
  To: misc@opensmtpd.org
  Subject: DSN problems
 
  Hi all,
 
  I just did a SMTP-GW migration from Sendmail to opensmtpd, now I 
  have
  big problem, the DSN report is really ugly :) and a lot of 
  users
  are
  confused if this is a error or what I know that I can 
  disable...
  but
  I have to do that in a hundred desktops
  The best way I think is do the same as Postfix/Sendmail for DSN, or
  better... disable the DSN support.
 
  DSN content structure is a work in progress...
  https://github.com/poolpOrg/OpenSMTPD/issues/432
 
 
  Another problem is a travel system that we use, the system send
  emails
  with some DSN Flag that opensmtpd is not supported.
 
 
  Could you provide some more details, which specific flag? logs?
 
 
  stat=501 5.5.4 Error: Bad NOTIFY parameter syntax
 
  Could you please run...
 
  smtpd -dv -Tsmtp
 

 After run this command I understand better. The main problem is when 
 opensmtpd receive the message with DSN flag and forward to Postfix, them 
 postfix reply to the sender and at this time opensmtpd cannot understand 
 the dsn reply from postfix, so I disable the DSN in Postfix, but is much 
 better have some way to disable DSN in opensmtpd. I'm still have the 
 logs.

Any DSN message shouldn't be delivered with DSN flags set and Postfix
does confirm to that behaviour. Without logs we keep guessing.

Anyways, on current OpenSMTPD (git HEAD) you can disable DSN with
no-dsn parameter to listen rule, see smtpd.conf(5).

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: DSN problems

2014-06-16 Thread Sunil Nimmagadda
  From misc+bounces-888-sunil=nimmagadda@opensmtpd.org Mon Jun 16 
  01:00:56 2014
  From: Ricardson Williams ricardsonwilli...@gmail.com
  To: misc@opensmtpd.org
  Subject: DSN problems
 
  Hi all,
 
  I just did a SMTP-GW migration from Sendmail to opensmtpd, now I have
  big problem, the DSN report is really ugly :) and a lot of users 
  are
  confused if this is a error or what I know that I can disable... 
  but
  I have to do that in a hundred desktops
  The best way I think is do the same as Postfix/Sendmail for DSN, or
  better... disable the DSN support.
 
  DSN content structure is a work in progress...
  https://github.com/poolpOrg/OpenSMTPD/issues/432
 
 
  Another problem is a travel system that we use, the system send 
  emails
  with some DSN Flag that opensmtpd is not supported.
 
 
  Could you provide some more details, which specific flag? logs?


 stat=501 5.5.4 Error: Bad NOTIFY parameter syntax

Could you please run...

smtpd -dv -Tsmtp

and share the logs, so that we can see the full SMTP commands,
especially RCPT TO: line.


-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: DSN problems

2014-06-15 Thread Sunil Nimmagadda
 From misc+bounces-888-sunil=nimmagadda@opensmtpd.org Mon Jun 16 01:00:56 
 2014
 From: Ricardson Williams ricardsonwilli...@gmail.com
 To: misc@opensmtpd.org
 Subject: DSN problems

 Hi all,

   I just did a SMTP-GW migration from Sendmail to opensmtpd, now I have 
 big problem, the DSN report is really ugly :) and a lot of users are 
 confused if this is a error or what I know that I can disable... but 
 I have to do that in a hundred desktops
   The best way I think is do the same as Postfix/Sendmail for DSN, or 
 better... disable the DSN support.

DSN content structure is a work in progress...
https://github.com/poolpOrg/OpenSMTPD/issues/432


   Another problem is a travel system that we use, the system send emails 
 with some DSN Flag that opensmtpd is not supported.


Could you provide some more details, which specific flag? logs?



 Thanks,
 Ricardson





 -- 
 You received this mail because you are subscribed to misc@opensmtpd.org
 To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: using SPF or DKIM instead of greylisting?

2014-05-30 Thread Sunil Nimmagadda
 On Fri, 30 May 2014 11:45:13 +0200, Ji=C5=99=C3=AD Navr=C3=A1til jiri@navr=
 atil.cz
 wrote:

  V 30. kv=C4=9Btna 2014 at 11:38:43, Gilles Chehade (gil...@poolp.org)
  naps=C3=A1no:
   What is your anti SPAM strategy please? Are available SPF and DKIM
   configurations examples for OpenSMTPD?=C2=A0
  =C2=A0
   Thak you for your recommendations.=C2=A0
  =C2=A0
 =20
  I only use greylisting and fopr big hosts like gmail and yahoo, I
  have a script that queries their SPF records to whitelist the MX
  servers that they advertise.=C2=A0
 =20
 =20
  Thank you for quick reply.
 =20
  That looks as reasonable way for me. Could you share your script,
  please?

 I have quite the same setup than Gilles, though I'm lazier so I use the
 list from Peter N. M. Hansteen : http://www.bsdly.net/~peter/nospamd

  Jiri Navratil

 Cheers,
 --=20
 Vigdis

I am using bgp-spamd.net whitelisting for my domain in addition to
spamd.  It currently has ~ 91825 whitelisted ips. I had a similar
experience with github trying to send a mail with different IP each
time when spamd grey-trapped the first attempt. bgp-spamd whitelisted
IPs had all the IPs with which github was trying to send mail.


-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Re: Turn off DSN

2014-03-04 Thread Sunil Nimmagadda
On Wed, Mar 05, 2014 at 05:31:03AM +0100, Jason A. Donenfeld wrote:
 Apparently delivery status notification allows anybody to determine
 where a piece of mail is relayed, by requesting a success
 notification. OpenSMTPD happily creates a nice verbose message
 containing this information.
 
 Except I don't want to let the world know where the mail is relayed.
 
 Any way to turn this off?
 
 -- 
 You received this mail because you are subscribed to misc@opensmtpd.org
 To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org
 

Is DSN requested by your MUA? If not smtpd shouldn't be generating
a DSN. If smtpd is used to relay a mail and DSN parameters were
specified then it's bound to generate the DSN.

I am confused whether you want to turn off DSN (which is generated
only on request) or you want to suppress some of the content of
the DSN.

-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Call for testing: Delivery Status Notification

2014-01-09 Thread Sunil Nimmagadda
Hi,

An implementation of RFC 3461 has been merged to master/portable
branches.  This feature allows a user to request a status notification
when a mail gets delivered successfully, failed to deliver or
gets delayed. It also allows to specify the amount of information
in the status notification, for example just the headers or full
original mail. It requires extensive testing in various setups(relaying
to DSN capable vs non capable servers) and with various MUAs. Request
you all to help in testing it and report any issues.

Some pointers for testing with these MUAs...

mutt:
In .muttrc
set dsn_notify=success
set dsn_return=hdrs

mail(1):
mail -s foo b...@baz.org -Nsuccess -Rhdrs

Thunderbird:
While composing a mail check Options-Delivery Status Notification


-- 
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org



Delivery Status Notification diff

2013-09-29 Thread Sunil Nimmagadda
Hi,

This diff implements Delivery Status Notification as specified in
RFC3461 for NOTIFY=SUCCESS case. OpenSMTPD can now relay DSN related
parameters to DSN capable server as well as advertises 250-DSN in
banner. It's now possible to mail -s subject f...@bar.org -N success
-R hdrs and get a notification from the relaying server. If OpenSMTPD
recieves a mail for which DSN is requested it now generates a DSN
to the sender.  Note though that this diff currently only works for
NOTIFY=success case, however, OpenSMTPD already handles delay and
failure as part of bounce handling.  The bounce generation is not
bound by DSN parameters yet. I tested it with postfix server and
would appreciate test reports against other DSN capable servers.

Comments?

diff --git a/smtpd/bounce.c b/smtpd/bounce.c
index ef3e345..7791f1b 100644
--- a/smtpd/bounce.c
+++ b/smtpd/bounce.c
@@ -93,6 +93,7 @@ static void bounce_status(struct bounce_session *, const char 
*, ...);
 static void bounce_io(struct io *, int);
 static void bounce_timeout(int, short, void *);
 static void bounce_free(struct bounce_session *);
+static const char *bounce_strtype(enum bounce_type);
 
 static struct tree wait_fd;
 static struct bounce_message_tree  messages;
@@ -317,6 +318,9 @@ const char *notice_warning2 =
 The message is kept in the queue for up to %s.\n
 You DO NOT NEED to re-send the message to these recipients.\n\n;
 
+const char *notice_success =
+Your message was successfully delivered to these recipients.\n\n;
+
 static int
 bounce_next_message(struct bounce_session *s)
 {
@@ -400,18 +404,28 @@ bounce_next(struct bounce_session *s)
\n
NOTICE_INTRO
\n,
-   (s-msg-bounce.type == B_ERROR) ? error : warning,
+   bounce_strtype(s-msg-bounce.type),
env-sc_hostname,
s-msg-to,
time_to_text(time(NULL)));
 
-   if (s-msg-bounce.type == B_ERROR)
+   switch (s-msg-bounce.type) {
+   case B_ERROR:
iobuf_xfqueue(s-iobuf, bounce_next: BODY,
notice_error);
-   else
+   break;
+   case B_WARNING:
iobuf_xfqueue(s-iobuf, bounce_next: BODY,
notice_warning,
bounce_duration(s-msg-bounce.delay));
+   break;
+   case B_DSN:
+   iobuf_xfqueue(s-iobuf, bounce_next: BODY,
+   notice_success);
+   break;
+   default:
+   log_warn(warn: bounce: unknown bounce_type);
+   }
 
TAILQ_FOREACH(evp, s-msg-envelopes, entry) {
iobuf_xfqueue(s-iobuf,
@@ -655,5 +669,21 @@ bounce_message_cmp(const struct bounce_message *a,
return memcmp(a-bounce, b-bounce, sizeof (a-bounce));
 }
 
+static const char *
+bounce_strtype(enum bounce_type t)
+{
+   switch (t) {
+   case B_ERROR:
+   return (error);
+   case B_WARNING:
+   return (warning);
+   case B_DSN:
+   return (dsn);
+   default:
+   log_warn(warn: bounce: unknown bounce_type);
+   return ();
+   }
+}
+
 SPLAY_GENERATE(bounce_message_tree, bounce_message, sp_entry,
 bounce_message_cmp);
diff --git a/smtpd/enqueue.c b/smtpd/enqueue.c
index b74efd8..4b6914c 100644
--- a/smtpd/enqueue.c
+++ b/smtpd/enqueue.c
@@ -105,6 +105,9 @@ struct {
char *from;
char *fromname;
char**rcpts;
+   char *dsn_notify;
+   char *dsn_ret;
+   char *dsn_envid;
int   rcpt_cnt;
int   need_linesplit;
int   saw_date;
@@ -161,7 +164,7 @@ enqueue(int argc, char *argv[])
char*fake_from = NULL, *buf;
struct passwd   *pw;
FILE*fp, *fout;
-   size_t   len;
+   size_t   len, envid_sz;
char*line;
int  dotted;
int  inheaders = 0;
@@ -175,7 +178,7 @@ enqueue(int argc, char *argv[])
save_argv = argv;
 
while ((ch = getopt(argc, argv,
-   A:B:b:E::e:F:f:iJ::L:mN:o:p:qR:tvx)) != -1) {
+   A:B:b:E::e:F:f:iJ::L:mN:o:p:qR:tvV:x)) != -1) {
switch (ch) {
case 'f':
fake_from = optarg;
@@ -183,12 +186,21 @@ enqueue(int argc, char *argv[])
case 'F':
msg.fromname = optarg;
break;
+   case 'N':
+   msg.dsn_notify = optarg;
+   break;
+   case 'R':
+   msg.dsn_ret = optarg;
+