PDA

View Full Version : sendmail and php


ffejy
4-28-02, 11:22 AM
I have used sendmail with perl before, but I don't know how to use it in PHP. Perhaps someone can point me in the right direction.

Thanks!

Atomic-Design
4-28-02, 12:57 PM
Oh it's easy.

$to = "someone@domain.com";
$subject = "hi";
$message = "This is the message that's in the email";
mail ($to, $subject, $message) or print "Couldn't send mail";

ffejy
4-28-02, 01:34 PM
Oh, so I don't need to tell it the path to sendmail, it can do it by itself? PHP is great! :)

Thanks!

Atomic-Design
4-28-02, 01:42 PM
For me, it sent it from my POP mail.

ffejy
4-28-02, 01:50 PM
you mean your powweb mail account?

Atomic-Design
4-28-02, 02:38 PM
Ya, I didn't have to configure anything, PHP just figured it out.

ffejy
4-28-02, 03:03 PM
Yes, it says in the docs that if you don't tell it the path to sendmail, it will find it. You can set it manually somehow too.

pieterhielema
4-29-02, 01:18 PM
Thanks a lot. I had reserved tonight to figure this out. Now I found this entry and are ready within 5 minutes...isn't live wonderfull?

Pieter
http://www.pbholland.com

nicey
4-29-02, 04:09 PM
You can also funk it up abit... adding a From address'n'**** :



.... using variable expansion for the message... and $to, etc, as stated in the posts above.

Want to send HTML messages? :

[php]
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


... set those variables up :

.... add $headers to the 'mail' command... and done.

nicey
4-29-02, 04:11 PM
... ooops.. forgot to say that in the $message, you gotta have HTML code, to send HTML.

ffejy
4-29-02, 05:33 PM
Yes, there are several nice examples in the docs that I looked at. :) http://www.php.net/manual/en/function.mail.php