Jump to content

PHP mail


Recommended Posts

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 ="[email protected]";

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 ="[email protected]";

$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 ="[email protected]";

Do i add it in my config file or on the same file/files where i see mail($recipient, $subjectcmmnt, $notifcmmnt, $headers)

 

helpppppppppp  :(

Link to comment
https://forums.phpfreaks.com/topic/164815-php-mail/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/164815-php-mail/#findComment-869090
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.