brinklow Posted July 5, 2009 Share Posted July 5, 2009 I have a php script on my site that needs to send an email to users when they join up, it has not been working for a while, everything else works, the account is setup and an authorisation code genereated. I decided to try and learn php and see if i can fix it, however i am not proving very successful, but i did read on my hosting site that they have had a recent server update. regarding php mail, customers who choose to use this method will need to include an extra variable in their code. What needs to be included is; 1. A variable that tells the script where the email is being sent from; For example; $SendEmail ="enquire@domainname.com"; 2. Adding this variable onto the end of the mail() function. Below is a very basic php script, I have included the extra entries in italic. $nameField = $_POST['name']; $emailField = $_POST['email']; $SendEmail ="enquiry@domainname.com"; $body = <<< EOD Name: $nameField Email: $emailField EOD; $headers = "From: $emailField\r\n"; $headers .= "Content-type: text/html\r\n"; $sucess = mail($webMaster, $emailSubject, $headers, $body, '-f'.$SendEmail); The important part here is the '-f'.$SendEmail at the end of the mail() function. The '-f' although not a php command is a sendmail parameter that is telling our mailserver the mail is being sent from the $SendEmail address and nowhere else. My problem is that im not sure which files in my script i need to edit, would i have to search through all files and add '-f'.$SendEmail whereever i see this part of code mail($recipient, $subjectcmmnt, $notifcmmnt, $headers) so that it looks like this mail($recipient, $subjectcmmnt, $notifcmmnt, $headers,'-f'.$SendEmail) and where do i add $SendEmail ="enquiry@domainname.com"; Do i add it in my config file or on the same file/files where i see mail($recipient, $subjectcmmnt, $notifcmmnt, $headers) helpppppppppp Quote Link to comment Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 You would need to search all your applications files for calls to the mail() function. It may use different variables as perimeters. As for where to keep your $SendEmail variable. If its the same in all places then you may as well define it within a commonly included file. Sounds to me however that your host has some sort of dodgy setup going on. You really needn't usually have to jump through these types of hoops just to get php to send mail. Quote Link to comment Share on other sites More sharing options...
brinklow Posted July 5, 2009 Author Share Posted July 5, 2009 ok, i will have a look to see if it might be something else causing the problem before i start changing the code, as there are a number of files that have the mail(). Would the read/write permissions cause a problem if they were accidently changed on any files? 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.