View Full Version : sendmail and php
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.
4-28-02, 01:57 PM
Oh it's easy.
$to = "email@example.com";
$subject = "hi";
$message = "This is the message that's in the email";
mail ($to, $subject, $message) or print "Couldn't send mail";
Oh, so I don't need to tell it the path to sendmail, it can do it by itself? PHP is great! :)
4-28-02, 02:42 PM
For me, it sent it from my POP mail.
you mean your powweb mail account?
4-28-02, 03:38 PM
Ya, I didn't have to configure anything, PHP just figured it out.
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.
4-29-02, 02: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?
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? :
$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.
... ooops.. forgot to say that in the $message, you gotta have HTML code, to send HTML.
Yes, there are several nice examples in the docs that I looked at. :) http://www.php.net/manual/en/function.mail.php
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.