PHP mail function not working on my Mac OS/X Snow Leopard
Posted: Mon Oct 25, 2010 1:54 pm
I am starting to learn PHP's mail() function and I am running into issues with the mail function.
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:
3. My actual lines of code in mail.php file looks like this:
<- I omitted my real address so it doesn't show up on this forum but my real address is in the code.
<- 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:
5b. Updated variable myhostname in the file main.cf
Then updated relayhost in main.cf and put in my smtp server name (in this example, it is google gmail).
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 have searched the internet and a lot of forums but have been finding that the people who asked the question have not received a response.
Many many thanks in advance!
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:
Code: Select all
sendmail_path = "/usr/sbin/sendmail -t"Code: Select all
$toaddress = "myemailaddress@myemailaddress.com";Code: Select all
$fromaddress = "From: myemailaddress@myemailaddress.com";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:
Code: Select all
MAILSERVER=-YES-Code: Select all
myhostname = example.yahoo.comCode: Select all
relayhost = smtp.gmail.comSaved 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 have searched the internet and a lot of forums but have been finding that the people who asked the question have not received a response.
Many many thanks in advance!