[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Send Mail - Open Mail
- To: Avi Boots <aviboots(at-nospam)netvision.net.il>
- Subject: Re: Send Mail - Open Mail
- From: "Alexander V. Karelin" <karelin(at-nospam)barak-online.net>
- Date: Tue, 12 Dec 2000 14:06:11 +0200 (IST)
- cc: linux-il(at-nospam)linux.org.il
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-Reply-To: <005b01c0642f$4ebb1d60$0301a8c0@com.c4info.com>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
Dear Avi!
There are several (actually a lot) of ways to send an Email on UN*X/Linux
systems. The way You are trying is the one that will not work, because I
don't think command indirection into a writable pipe is something
available on Linux... But - it's a nice idea for a feature, may be we
should suggest that to Linus:)
Now - for the way I find the simplest of all in sending
Emails. (BTW: Please note, this is not the absolute and only way to send
an Email, it is just that I find it comfortable)
1. In the Makefile/Configure pair, arrange a section that searches for
"sendmail" executable. If You don't have a Makefile/Configure pair, just
find the sendmail executable. It is usually in /usr/sbin.
2. Once You have that (i.e. the exact location of sendmail), You can use
it to send Email. To send an Email (theoretically) You have to run
sendmail with the following parameters: /usr/sbin/sendmail -f [from
address] [recepients list]. For example:
/usr/sbin/sendmail -f sender@mydomain.com friend1@hisdomain.com,
friend2@otherdomain.com
3. Now - when sendmail is being launched with the parameters explained
above, it expects to receive the body of the messge from stdin. In order
to provide it (sendmail) with this highly important particle, You can just
put the Email text in a temporary file, and cat that while through pipe
for sendmail. For example:
cat /tmp/mymailtext | /usr/sbin/sendmail -f sender@mydomain.com
friend1@hisdomain.com, friend2@otherdomain.com
4. Ok - now, when we actually have some information on HOW sendmail has to
be operated, let's see how we do that in our code.
4.1 Generate a temporary filename (or use temporary files subsystem). The
easiest way to generate a temporary filename, is to name one after Your
pid (proccess ID). getpid() returns the id.
4.2 Write the temporary file.
4.3 Run cat and sendmail with all the parameters as described in 3. The
most comfortable way I found for running sendmail in such a case is to use
"system" function. But there are too many alternatives, so I don't want to
get into this.
4.4 Delete the temporary file.
4.5 Go for a walk:)
That's it... I hope it helps. Besides being a bit too extensive (and quite
boring for most people here, I guess) this demonstrates one of the 50 ways
to send an Email on linux. Have fun!
On Tue, 12 Dec 2000, Avi Boots wrote:
> Hi,
>
> I run this code to send a simple mail:
> and i can't open mail:
>
> fp = popen("mail myfriend@hotmail.com", "w");
> (fp = NULL can't open mail...)
> fprintf("%s", msg);...
> (System: Linux RH 6.1 with apache)
>
> If anyone now how to send mail true c source
> i'll be very happy to here his advise
>
> Thank you,
> Avi Boots.
>
>
>
>
>
> =================================================================
> To unsubscribe, send mail to linux-il-request@linux.org.il with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail linux-il-request@linux.org.il
>
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il