mail() function is not working

the mail() function

Moderators: macek, egami, gesf

User avatar
IPhoton
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Aug 31, 2011 10:32 am
Contact:

mail() function is not working

Postby IPhoton » Mon Sep 05, 2011 5:57 am

Hiii,

I'm receiving a problem:-
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\error.php on line 47


My php.ini file's configuration:-

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = admin@localhost.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; 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 =


Can Any-One Help Me ???????

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: mail() function is not working

Postby Nullsig » Tue Sep 06, 2011 6:08 am

are you using windows or UNIX to run your PHP server?

User avatar
IPhoton
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Aug 31, 2011 10:32 am
Contact:

Re: mail() function is not working

Postby IPhoton » Tue Sep 06, 2011 7:35 am

Nullsig wrote:are you using windows or UNIX to run your PHP server?


I'm using :-

1). Windows 7
2). Apache 2.2.19
3). PHP 5.2.17
4). MySQL 5.5.15
5). PHPMyAdmin 3.4.4

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: mail() function is not working

Postby Nullsig » Tue Sep 06, 2011 7:39 am

Did you install the WAMP package or all of it separately?

I would try un-commenting the following line:

Code: Select all

sendmail_from = admin@localhost.com


or include the following header in the mail message:

Code: Select all

$header = "From: admin@localhost.com" . "\r\n";


Replace the "admin@localhost.com" with whatever e-mail address you want the receiver to see it coming from.

User avatar
IPhoton
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Aug 31, 2011 10:32 am
Contact:

Re: mail() function is not working

Postby IPhoton » Tue Sep 06, 2011 7:51 am

*I'm not using WAMP Server (all things are individuals)

*My php.ini config:-
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = admin@localhost.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =


*My error :-
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\error.php on line 47


*My PHP Code :-

Code: Select all

echo '<p><a href="mailto:admin@localhost.com">Contact</a> the system administrator if you feel         this to be in error.</p>';

 $now = (isset($_SERVER['REQUEST_TIME'])) ? $_SERVER['REQUEST_TIME'] : time();
 $page = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : 'Unknown';
 
 $msg = wordwrap('A '.$_SERVER['QUERY_STRING'].' error was encountered on '.date('F d, Y', $now).' at '.date('H:i:sa T', $now).' when a visitor attempted to view '.
                                                                                  $page.'.');
 
 mail('admin@localhost.com', 'Error from Website', $msg);


Helpppppppppppppppp?????

User avatar
IPhoton
New php-forum User
New php-forum User
Posts: 13
Joined: Wed Aug 31, 2011 10:32 am
Contact:

Re: mail() function is not working

Postby IPhoton » Tue Sep 06, 2011 7:59 am

After removing semi-colon from sendmail_from = admin@localhost.com.
And After Restarting Apache Server.

I receiving new error :-
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: mail() function is not working

Postby Nullsig » Tue Sep 06, 2011 8:04 am

This would be where my assistance will begin to falter.

To be honest I use Linux to run my PHP servers and therefore have never had the... lets call it a privilege... of dealing with Windows and send_mail. I would check to make sure you have SMTP correctly configured for IIS.

All I can do to help you with that is refer you to this walk through.

http://www.ruhanirabin.com/php-sendmail-setup-with-smtp-iis-and-windows-servers/


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest