looking for small SMTP lib?
looking for small SMTP lib?
am 26.10.2007 16:41:09 von Jonathan de Boyne Pollard
RW> Below is a part of a 'mail sending script' used for
RW> some time on the appliances I mostly work for:
RW>
RW> cd $temp
RW> printf "HELO lamer\r\n" >header
RW> printf "MAIL FROM: %s\r\n" "$addr" >>header
RW> printf "RCPT TO: %s\r\n" "$addr" >>header
RW> printf "DATA\r\n" >>header
RW>
RW> printf ".\r\nQUIT\r\n" >trailer
RW>
RW> cat header - trailer | nc "$server" 25
RW>
RW> It should be easy to adapt this for C.
.... and when you do, remember to fix the several bugs that it has.
Angle brackets are mandatory in the MAIL and RCPT verbs, and so is dot-
stuffing for the message data. Sending message data and the end of
data indication is prohibited unless there is a positive
acknowledgement to the DATA verb. (The consequences of sending
arbitrary data when the sever is not actually in the receiving message
data state should be obvious.) Don't contribute to furthering
Gresham's Law when it comes to SMTP. If you are going to write an
SMTP Submission client, write a correct one.
Re: looking for small SMTP lib?
am 27.10.2007 03:09:44 von Barry Margolin
In article <1193409669.201203.211210@50g2000hsm.googlegroups.com>,
J de Boyne Pollard wrote:
> If you are going to write an
> SMTP Submission client, write a correct one.
Which explains why the OP is looking for a library, and why this is a
Good Thing. He presumably knows that he doesn't know the SMTP protocol
well, so anything he cobbled together would probably not be fully
correct. One hopes that a library that people recommend would implement
the protocol well.
I'm not sure there are many such libraries, though. Most Unix
applications that need to send mail simply exec a program like mail,
mailx, or sendmail.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Re: looking for small SMTP lib?
am 27.10.2007 15:36:53 von DFS
Barry Margolin wrote:
> I'm not sure there are many such libraries, though. Most Unix
> applications that need to send mail simply exec a program like mail,
> mailx, or sendmail.
There are SMTP client libraries. If you're willing to use Perl,
Net::SMTP is not bad. A free C library is
http://www.stafford.uklinux.net/libesmtp/
-- David.
looking for small SMTP lib?
am 28.10.2007 00:37:48 von Jonathan de Boyne Pollard
BM> I'm not sure there are many such libraries, though.
BM> Most Unix applications that need to send mail
BM> simply exec a program like mail, mailx, or sendmail.
That was specifically ruled out as a solution. But I did wonder at
the thinking behind that restriction. I suspect that it is
misguided. I suspect that there is no inherent reason that the
application cannot fork() and execve() a mail submission utility
program; and that the thinking is that it is intended, probably for
security reasons, that the host system should not have a full MTS
installed. In which case, it would be incorrect to entirely rule out
using a submission utility program. There are plenty of ways in which
a system can be set up with a small, secure, MTS, without an SMTP
server, a queue, local delivery, or other such accoutrements, whose
submission utility simply passes all submitted mail straight over to
another system for handling. One could quite easily use "mini-
qmail" (), for example, and have
the normal fork-and-exec-the-submission-utility approach in one's
application.
looking for small SMTP lib?
am 30.10.2007 17:25:30 von Jonathan de Boyne Pollard
RW> Below is a part of a 'mail sending script' used for
RW> some time on the appliances I mostly work for:
RW>
RW> cd $temp
RW> printf "HELO lamer\r\n" >header
RW> printf "MAIL FROM: %s\r\n" "$addr" >>header
RW> printf "RCPT TO: %s\r\n" "$addr" >>header
RW> printf "DATA\r\n" >>header
RW>
RW> printf ".\r\nQUIT\r\n" >trailer
RW>
RW> cat header - trailer | nc "$server" 25
RW>
RW> It should be easy to adapt this for C.
JdeBP> ... and when you do, remember to fix the several bugs that it
JdeBP> has. [...]
RW> The point of this script was to send a mail to a
RW> particular mail server. Which it did.
It does not operate correctly. I pointed out the several problems,
one of which would corrupt messages and two of which are egregious
security holes that can potentially be exploited to create an open
relay, in the portion of the message that you skipped over above.
(There's a third security hole that I didn't point out, but that
people familiar with PHP scripts that send mail from web forms should
be familiar with.) The script simply does not implement the protocol
at all.
RW> This is called 'a quick hack', a concept you
RW> don't seem to be familar with.
I see that once again you have resorted to accusing the poster when
you lack any technical foundation for discussing the subject at hand.
A correct description for what you have above is not "quick hack", but
"yet another half-baked and incorrect SMTP client that contributes to
furthering Gresham's Law". It is an SMTP client that is broken and
should not be used, especially not as a model for other people to
develop SMTP clients of their own from.