Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-23-2006, 09:41 PM   PM User | #1
php_leg_end
New Coder

 
Join Date: Nov 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
php_leg_end is an unknown quantity at this point
mail() - not sending on local server

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:

Quote:
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?
php_leg_end is offline   Reply With Quote
Old 11-23-2006, 10:05 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
Look in php.ini

Find the following lines. (around line 602)
[mail function]
; For Win32 only.
SMTP = localhost

change that value to your SMTP server.

you can use your adsl or broadband provider's smtp.

good luck.
Ess
ess is offline   Reply With Quote
Old 11-23-2006, 10:09 PM   PM User | #3
php_leg_end
New Coder

 
Join Date: Nov 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
php_leg_end is an unknown quantity at this point
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..?
php_leg_end is offline   Reply With Quote
Old 11-23-2006, 10:14 PM   PM User | #4
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,711
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
You can also do this in your PHP code -
PHP Code:
ini_set('SMTP','yoursmtpserver'); 
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is offline   Reply With Quote
Old 11-24-2006, 01:22 PM   PM User | #5
php_leg_end
New Coder

 
Join Date: Nov 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
php_leg_end is an unknown quantity at this point
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...
php_leg_end is offline   Reply With Quote
Old 11-24-2006, 03:35 PM   PM User | #6
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,711
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
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/
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

Last edited by CFMaBiSmAd; 11-24-2006 at 03:37 PM..
CFMaBiSmAd is offline   Reply With Quote
Old 11-25-2006, 07:01 PM   PM User | #7
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
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...

good luck.
ess
ess is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting 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

Forum Jump


All times are GMT +1. The time now is 12:40 AM.


Advertisement
Log in to turn off these ads.