Lassie Posted December 5, 2006 Share Posted December 5, 2006 Thanks to everbody who has previously tried to help me with this but unfortunately I am making no headway.My mail function refuses to work.I have set the php.inito reflect my server address which is on the same machine and set the send mail from field.The settings are[mail function]SMTP=213.210.25.37sendmail_from=hawkesley_2jags@yahoo.co.ukI have written a test script to check mail is working as follows<?php $to = "hawkesley_2jags@yahoo.co.uk"; $subj = "test"; $mess = "This is a test of the mail function"; $headers = "From:Hawkesley House<hawkeslehouse@btinternet.com>\r\n"; mail($to,$subj,$mess,$headers); if ($mailsent){ echo "Test message sent"; } else { echo "There was an error"; } exit();?>I have checked that the SMTP server on the machine works by getting it to send an email via telenetI get the following errorWarning: Unknown error in c:\easyserv\www\e_cart7\test_mail3.php on line 7There was an errorI have looked at the php manual but cant find an obviuos clue.Can anyone help please. Is there a way to reveal the unknown error?Desperate for advice. Quote Link to comment Share on other sites More sharing options...
thedarkwinter Posted December 5, 2006 Share Posted December 5, 2006 HiSorry i don't have any conclusive answers, but 1 or 2 suggestions...1. Experminet with the SMTP server address dynamically:in the code, (instead of php.ini) ini_set("SMTP", "localhost"); // try localhost and 127.0.0.1, some routers etc will not loopback on public ip addresses etc... can cause problems mail($to,$subj,$mess,$headers); ini_restore("SMTP");2. Remove the sendmail_from directive/or the from section in $headers, the smtp server may be rejecting the mail if its from 2 different addresses(?)3. Check that you smtp server software will relay for the from addresses, i'm not sure the windows config but in linux postfix you have config like relaydomains=btinternet.com,yahoo.co.ukHope at least something there is helpfulCheers,tdw Quote Link to comment Share on other sites More sharing options...
Lassie Posted December 5, 2006 Author Share Posted December 5, 2006 Thanks. I will try that. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 5, 2006 Share Posted December 5, 2006 You have:[code]<?php mail($to,$subj,$mess,$headers); if ($mailsent){ echo "Test message sent"; } else { echo "There was an error"; }?>[/code]but you don't set the variable $mailsent before the "if" statement.Try:[code]<?php $mailsent = mail($to,$subj,$mess,$headers); if ($mailsent){ echo "Test message sent"; } else { echo "There was an error"; }?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Lassie Posted December 6, 2006 Author Share Posted December 6, 2006 Thanks KenI did spot that and changed it but it has made no difference.Is it right to assume that a straight forward installation of php will have the mail function? Does Pear have to be configured at all?Thanks if you have a view.lassie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.