Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

amy.damnit

macrumors newbie
Original poster
Jan 8, 2009
20
0
Illnois
Hi all. I am learning PHP and would like to set up an SMTP email server on my MacBook so that I can practice sending e-mails via PHP.

Once I feel comfortable getting my PHP test scripts to send out e-mails from my laptop, then I'll probably look into using a web host's e-mail servers.

I believe that SendMail and some other program may already be install on my MacBook with OS X 10.5, however nothing is obvious. And when I Googled, I just saw a few cryptic websites describing random command line instructions that seemed incomplete.

It would seem my goal should be fairly easy to do?! :confused:

Any guidance would be greatly apprciated!!

Thanks,


Amy
:)
 
When I test at home I use my ISP's SMTP server. I believe I edited something in the php.ini file to tell it the server. I'm not at my home machine so can't look specifically.
 

Thanks for the link, but if I do that, how do you actually launch Postfix?

And a bigger question...

Is it dangerous to enable and run an SMTP server from my home laptop?

I would like to get actual hands-on experience writing PHP code to send e-mails, but do not want to expose my local MacBook to any viruses, spam, and what-not in doing so.

What do you say about all of this?

Thanks,


Amy
 
Did you ever find the fix to this?

I too am starting to learn PHP's mail() function and here's what I run into:

1. First, I am running everything on localhost so that I can test/sandbox my work. I do not have my own Internet domain name yet, it's all localhost.

2. My php.ini has been updated as follows:
sendmail_path = "/usr/sbin/sendmail -t"

3. My actual lines of code in mail.php file looks like this:
$toaddress = "myemailaddress@myemailaddress.com"; <- I omitted my real address so it doesn't show up on this forum but my real address is in the code.

$fromaddress = "From: myemailaddress@myemailaddress.com"; <- I omitted my real address so it doesn't show up on this forum but my real address is in the code.

4. I run the html file (it is a simple feedback form that executes the mail.php file) in my localhost browser and submit the form. I get NO visible errors when I submit (i.e. it echoes the success response to my browser). HOWEVER, I am trailing the mail log in my Terminal and it shows that multiple "Operation timed out" responses. Additionally, my mailq file shows all of my 30 attempts to submit the email (i.e. 30 times that I clicked "send" in the html form).

5. I then used the following from scripts I could gather on the Internet, none of these worked either.

5a. Updated the hostconfig file by adding the following line:
MAILSERVER=-YES-

5b. Updated variable myhostname in the file main.cf
myhostname = example.yahoo.com
Then updated relayhost in main.cf and put in my smtp server name (in this example, it is google gmail).
relayhost = smtp.gmail.com

5c. I also changed the SMTP port to 2525 in the php.ini file.

Saved my files, gracefully restarted Apache, reloaded postfix, opened up the Terminal and started my tail. Executed my html form (and subsequently the mail.php) and still get the "Operation timed out" response in the tail with all my attempts getting queued up in the mailq.

I am stuck -- all I want to do is experiment with the mail() function in PHP on my localhost Macbook Pro without actually sending email. Do I just need to go the distance and get a domain name with a mail server in order to try this?
 
I would guess that your ISP (internet service provider) is blocking the traffic. Hosting a site and sending email via the site on some ISP violates the terms of agreement so you should check with them on this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.