|
Home > Archive > Unix Programming > October 2007 > looking for small SMTP lib?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
looking for small SMTP lib?
|
|
| J de Boyne Pollard 2007-10-26, 1:29 pm |
| 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.
| |
| Barry Margolin 2007-10-27, 1:32 am |
| In article <1193409669.201203.211210@50g2000hsm.googlegroups.com>,
J de Boyne Pollard <j.deboynepollard@tesco.net> 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 ***
| |
| David F. Skoll 2007-10-27, 1:26 pm |
| 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.
| |
| Rainer Weikusat 2007-10-28, 1:24 pm |
| J de Boyne Pollard <j.deboynepollard@tesco.net> writes:
> 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.
The point of this script was to send a mail to a particular mail
server. Which it did. This is called 'a quick hack', a concept you
don't seem to be familar with. It is, however, not entirely uncommon
when people are supposed to work according to deadlines and write
software for their own, internal use only, meaning, they are not
professors of mathematics, earning more money than is probably good
for them with lots of spare time on their hands.
Got that?
| |
| Rainer Weikusat 2007-10-28, 1:24 pm |
| J de Boyne Pollard <j.deboynepollard@tesco.net> writes:
> 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.
The point of this script was to send a mail to a particular mail
server. Which it did. This is called 'a quick hack', a concept you
don't seem to be familar with. It is, however, not entirely uncommon
when people are supposed to work according to deadlines and write
software for their own, internal use only, meaning, they are not
professors of mathematics, earning more money than is probably good
for them with lots of spare time on their hands.
|
|
|
|
|