Click to See Complete Forum and Search --> : sending email with perl


TheLinuxDuck
01-22-2001, 04:31 PM
I came across this qool thing when writing a suggestion form script for a friend, thought it was tres qool. http://www.linuxnewbie.org/ubb/smile.gif


if(open (MAIL, "|-", "/usr/sbin/sendmail -oi -n -t")) {
print MAIL $buffer;
close(MAIL);
}

Of course, data sent must contain:

To:toname@domain.ext
From:fromname@domain.ext
message body


It is pretty rockin' groovy, though. http://www.linuxnewbie.org/ubb/smile.gif

I like perl.


------------------
TheLinuxDuck
I have a belly button.
:wq

Sweede
01-22-2001, 05:30 PM
PHP:
mail($from,$subject,$body,$headers);

or

$mail = fopen("/usr/sbin/sendmail -blah",'r');
fwrite($mail,$email_Data);
fclose($mail);

where email_data contains the formated headers and message like LinuxDuck has above.

http://www.linuxnewbie.org/ubb/smile.gif

Energon
01-22-2001, 05:38 PM
Originally posted by Sweede:
PHP:
mail($from,$subject,$body,$headers);


I love PHP... http://www.linuxnewbie.org/ubb/smile.gif

Sweede
01-22-2001, 07:37 PM
Another cool thing about the mail() function in php is that it doesnt matter if you develop on a Win32 box without a SMTP server (in php.ini , put host of your ISP's smtp), and then run the script on a *nix box with Qmail with 0 code change (Not even paths, PHP understands that /apache/htdocs is also c:\apache\htdocs )

klamath
01-22-2001, 07:55 PM
You can get the same effect in Perl using Net::SMTP from CPAN. So Perl lets you do it either way.

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the Tornado HTTP Server (http://sourceforge.net/projects/tornado)