Mail Script not sending mail...

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
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Mail Script not sending mail...

Post by phpnewbie1985 »

Ok I have made a test page where it sends a simple message to my address the following code is...

Code: Select all

<?
$to = "my-mail@btopenworld.com";  
$headers  = "MIME-Version: 1.0\r\n";  
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";  
$headers .= "From: ".$_POST['frmail']."\r\n";  
$mail =  @mail($to,$_POST['subj'],$_POST['msg'],$headers);  

// The "@" sign before the mail() call suppresses printing of errors 
// that may occur.  The test below will check for errors instead: 

if(!$mail){  
    echo "Email not sent! Please try later...";  
}else{  
    echo "Mail sent successfully!";  
}
?>
The problem is when i click the send button it says "e-mail not sent! blah blah blah," can anyone tell me why this is happening according to my server it is all set up. http://www.foci.co.uk/phpcheck.php

Any help would be gratfully received

Chris
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Chris,

Hmmmm im not sure but have you tried it without the "headers"? i think you may have a problem with the headers...i dont tink its done correctly....i have posted some mail scripts search for my name under "mail()" and see what you come up with maybe it may prove some help

Kendall
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

as is the common problem with sendmail.......

........check your configuration in php.ini
this is nearly always the problem

hope this helps
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Post by phpnewbie1985 »

how do i check that? :S sorry if i sound dumb
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

on windows c:windows-php.ini
on linux - cant remember

theres some configuration options for mail

have a look at that, it will not owkr if you havent already configured it
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Post by phpnewbie1985 »

i cant check that though as this is not my server i am paying for the space...
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

create a page and do this

<?php
php_info()
?>

that should tell you config options for PHP

you will have to get your host to set up mail then ( at a price probably)
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Post by phpnewbie1985 »

I have already got that page up...

i dont know what im meant to be looking for http://www.foci.co.uk/phpcheck.php is the page i made with that script on have a look...
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

sendmail_from me@localhost.com me@localhost.com
sendmail_path no value no value
change them to whatever applies to you
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Post by phpnewbie1985 »

and to do tat i have to ring my host?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

more than likely, i havent bothered with send-mail so i couldnt tell you, however i believe you have to be able to have direct access to your PHP.ini to use it
phpnewbie1985
Forum Commoner
Posts: 33
Joined: Thu Jan 08, 2004 6:15 am

Post by phpnewbie1985 »

ah ok cheers, you have been really helpful!
Chris
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

The sendmail_path only applies to *nix machines. The phpinfo() in this case indicates it is running on a windows box therefore the sendmail_path should not have a value.

The sendmail_from value is the default value to use if from is not specified within your mail function call.

Assuming the SMTP address is valid it looks like mail is setup correctly.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i was just trying to give ideas about what is possibly wrong
Post Reply