Page 1 of 2

mail()

Posted: Sun Feb 20, 2005 5:12 pm
by C_Calav
Hi guys,

im trying to code this mail() for the first time.

i got this error, and did some google'n and saw that i was missing the from parameter. i put it in and still got the error.

here is my error:
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2\htdocs\survey\launch_email.php on line 46
and here is my code so far:

Code: Select all

<?php


$mailto = "***";
$subject = "Thank you for signing up for our conference";
$body = "Hello Chris!";
$from = "Your Name <youremail@yourdomain.com>";


mail($mailto,$subject,$body,$from); 


?>
thanx

PS: for some reason i cannot use the search on this site properly when i am at work?

at home it works fine but at work when i seach and click on a link it goes to a blank white page. very weird. it has nothing to do with a fire wall or blocking of sites etc.

Posted: Sun Feb 20, 2005 5:14 pm
by feyd
you didn't specify the "From: " part.. :P

Posted: Sun Feb 20, 2005 5:25 pm
by C_Calav
is this better?

still getting same error

Code: Select all

<?php

$mailto = "***";
$subject = "Thank you for signing up for our conference";
$body = "Hello Chris!";
$headers = "From: C C <***@hotmail.com>"; 

mail($mailto,$subject,$body,$headers); 

?>
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2\htdocs\survey\launch_email.php on line 46

Posted: Sun Feb 20, 2005 5:30 pm
by C_Calav
PS: im in a localhost enviroment, does that make a difference?

Posted: Sun Feb 20, 2005 6:45 pm
by Chris Corbyn
What happens if you take out the name in your from field and just leave a plain old email address?. Also try adding

Code: Select all

"\r\n"
to the end of the $headers.

I know it shouldn't make a difference but it's possible there's a bug... have you got the sendmail_from value defined in php.ini?

Grrr... feyd's filter got me :lol: 'R'

Posted: Sun Feb 20, 2005 7:13 pm
by C_Calav
hi d11wtq,

i have not touched my php.ini file, it is

;sendmail_from = me@example.com

at the moment. do i need to change it?

Posted: Sun Feb 20, 2005 7:15 pm
by Chris Corbyn
It shouldn't really matter if you specify your own headers but give it a go .... just uncomment it. Also if you haven't touched PHP.ini you probably need to set up your smtp settings before mail() will work ;-)

Posted: Sun Feb 20, 2005 7:48 pm
by C_Calav
so i can use the mail() and test to see if eveything is working ok? thats good.

how should i setup my php.ini file?

is there a certain way for localhost? or a link i can have a read of or something?

this is what i got so far, just default
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com
thanx

Posted: Sun Feb 20, 2005 7:59 pm
by John Cartwright
uncomment

;sendmail_from = me@example.com

Posted: Sun Feb 20, 2005 8:05 pm
by Chris Corbyn
Is your smtp server running on localhost? If it is then that all would be good but otherwise you need to specify the smtp provided by your ISP..

This is mine
[mail function]
; For Win32 only.
SMTP = smtp.ntlworld.com
smtp_port = 25

; For Win32 only.
sendmail_from = xxxxxxx@ntlworld.com

Posted: Sun Feb 20, 2005 8:36 pm
by C_Calav
ok i have setup my php.ini file.

the file was wunder c:/winnt/php.ini

that is the correct location of the php file right?


still get the same error with this setup.

what else could be wrong?
[mail function]
; For Win32 only.
SMTP = puccini.steel.xxxxx
smtp_port = 25

; For Win32 only.
sendmail_from = postmaster@xxxx

Posted: Sun Feb 20, 2005 8:40 pm
by Chris Corbyn
Did you try \r\n after the header and removing the name and < >? That should be your php.ini yes but run php_info() to check. You can also see what it's reading as your mail settings too.

Posted: Sun Feb 20, 2005 8:51 pm
by C_Calav
ok i will do those changes and let you know.

one more question, i had a look at my info.php file and the

SMTP says localhost

and sendmail_from says no value.

now i just changed them both before why is this?

thanx

Posted: Sun Feb 20, 2005 8:56 pm
by Chris Corbyn
What does this line say in the output?
Configuration File (php.ini) Path C:\WINDOWS\php.ini
If it's c:\winnt\php.ini it's ok then i'd look further down your ini file... it must be overwriting the values somewhere

Posted: Sun Feb 20, 2005 9:00 pm
by evilmonkey
Make sure you have an SMTP server installed on your windows machine.