11-23-2006, 10:41 PM
Ok, some of you so far have helped me with my current project and I'm eternally grateful (well, for a few weeks anyway.. ;) ), but I'm now having a problem with the PHP mail() function.
I have the following code:
mail($email, "title blah blah", $password);
The variables are being passed in, I've checked, and I've even hardcoded the values in just to double check, yet I have no mail.
Thing is, I'm running this on an Apache server on my local machine. This isn't live, nor will it ever be, but I do need to demonstate it working. Can I send mail() across t'internet whilst on running on a local server? Preferably without re-configuring Apache/PHP? Is this my problem? Or am I just doomed to a life of producing grim code that doesn't work?
Look in php.ini
Find the following lines. (around line 602)
; For Win32 only.
SMTP = localhost
change that value to your SMTP server.
you can use your adsl or broadband provider's smtp.
11-23-2006, 11:09 PM
Thanks, I'll give that a try tomorrow.
Is there no way it can be done without making configuration changes. This is for a uni project and I don't really want the extra hassle/risk of making configuration changes before demonstrating..?
11-23-2006, 11:14 PM
You can also do this in your PHP code -
11-24-2006, 02:22 PM
Neither of these solutions are working for me. Is there something I'm missing?
I used the smtp server listed on my broadband account. No mail. Nothing in spam folder. Surely it can't be that complicated to process one line of code...
11-24-2006, 04:35 PM
Actually, due to spamming and abuse, it is somewhat complicated to successfully send an email and have it received in an in box.
From the mail(...) function code usage listed in your first post, no FROM address is present. All email must have a from address in order for it to be accepted by a mail server. Since you probably don't have a default from address entered in your php.ini and one was not entered in the mail(...) function call, the mail server probably rejected the email.
If you show the actual code you are using you can probably get a more specific answer as to why this might not be working.
Since you are sending from a script on a development system located somewhere on the Internet, this will look like an email client is connecting and sending the email and the mail server probably requires authentication against your mail box on it before it will accept an email. If this is the case, you cannot use the PHP mail(...) function as it does not support authentication. You would need to use something like the phpmailer class - http://phpmailer.sourceforge.net/
I have tried CFMaBiSmAd suggestion...and it worked like a charm on my local machine.
I think you should check if your firewall would allow Apache to access the internet. One way to do this is to disable the firewall whilst trying to send the email...
if that doesn't work...it can only mean that the SMTP server you are using is not allowing you to send emails. So, you should test if the SMTP works in an application like Outlook...