PHP mail() function problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rajesh Kumar
Forum Newbie
Posts: 2
Joined: Sat Feb 27, 2010 8:34 pm

PHP mail() function problems

Post by Rajesh Kumar »

I tried using PHP's mail() function for my website's "Forgot Password" page. It didn't work.

Next i tried configuring my php.ini file and that also did not work.

Finally i tried using sendmail and that also did not work....everything in vain...Please help.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PHP mail() function problems

Post by s.dot »

There are so many possible reasons why this is not working it would be impossible to diagnose without seing your code and/or error messages you are receiving.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Rajesh Kumar
Forum Newbie
Posts: 2
Joined: Sat Feb 27, 2010 8:34 pm

Re: PHP mail() function problems

Post by Rajesh Kumar »

part of my php.ini file below: I'm a newbie to PHP. :banghead: so explain everything in detail. NOTE: I'm using PHP under Windows(win7) using XAMPP

[mail function]
; For Win32 only.
;http://php.net/smtp
SMTP =localhost
;http://php.net/smtp-port
smtp_port =25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"
lshaw
Forum Commoner
Posts: 69
Joined: Mon Apr 20, 2009 3:40 pm
Location: United Kingdom

Re: PHP mail() function problems

Post by lshaw »

Unless you have configured mercury mail server included with XAMPP, you will not be able to use 'localhost' as the SMTP server

Try: http://www.youtube.com/watch?v=_QnfF64rA78

Edit: This will not allow you to send email to online accounts, just other local accounts but you can use it for testing
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PHP mail() function problems

Post by s.dot »

Yes, you will need a mail server. You can download free SMTP servers for windows.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply