Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP mail() help

PHP mail() help
Thread Tools
Grizzled Veteran
Join Date: Aug 2002
Location: Springfield, Oregon
Status: Offline
Reply With Quote
Mar 2, 2003, 08:13 PM
 
Hello All,

I am trying to create e-mail by using the mail() function in php. I have my machine set up the corret way, and I am serving the file from local host.

After I create the mail.php file (I know that it doesn't have to be called this, I am just doing it for S&G factor), I go to http://localhost/mail.php and I see the expected results but I never recieve the e-mail!

Here is the code that I am using:

<?
$result = mail("rclark2@gladstone.uoregon.edu", "test", "Let me know if this worked man.\nI");

if($result = true)
{
print "It sent!";
}
else
{
print "Nope, try again!";
}
?>

If anyone has any suggestions on developing php on my osx machine, I would greatly apreciate it. My email is above in the "to" parameter...Though I will be looking for ansers here in this form as well.

Thanks guys / gals!

P.S. For some reason, this forum is not allowing the open php tag, so that part is really there on my machine....<?
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Mar 3, 2003, 04:42 AM
 
Have you configured your Mac/PC to use Sendmail properly? It's quite a task, and one that's prone to many late nights and bad coffees...

There's a topic on the Mac OS X discussions (may be a week or two old) that talks about setting up Sendmail on a Mac OS X client box. That's the key to it. Once you've got that set up there's very little else that needs to be configured to get PHP to work with mail().
Computer thez nohhh...
     
Mac Enthusiast
Join Date: Apr 2001
Location: NYF'nC
Status: Offline
Reply With Quote
Mar 3, 2003, 09:24 AM
 
If ($result = true) is always true because you are assigning the value of true to $result. Try
Code:
if ($result == true) {
or
Code:
if ($result) {
or even better:
Code:
if (mail(rclark2@gladstone.uoregon.edu", "test", "Let me know if this worked man.\nI")) {

Jim Rockford was beaten repeatedly for your entertainment.
     
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Mar 3, 2003, 10:06 AM
 
Not meaning to hijack but, sendmail is known to be a pain to get going on X< cause every software update changes permissions that sendmail doesn't like. Is there a way to make PHP use a standard SMTP server for email? I have Apple's SMTP server running on my Server and using that, or any other instead, would seem to be alot easier. Back when i used to have a UBB running on a Mac, instead of using sendmail, i choose the windows option and selected SMTP Server, typed the machines own IP, and it worked perfectly.
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Mar 3, 2003, 11:23 PM
 
Originally posted by l008com:
Is there a way to make PHP use a standard SMTP server for email?
Yep, the nice folks at phpclasses.net have written a mail class that allows you to automate the whole process - you add text/html/images and other attachments automatically, specify your recipients and then the SMTP server details and voila!
Computer thez nohhh...
     
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Mar 3, 2003, 11:25 PM
 
But what about a way to make all scripts that use mail, like guestbooks and even this vBulletin, use SMTP instead of sendmail? Instead of just writing scripts specifically for them.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2