Hi I am trying to add a function to a php file and when a user access it to send me a mail with some info but i get the mail 15 times at once Is is anyway to limit to one? Or everytime that i change directory or server to send mail only once? This is the code that i add at the top of the rest of the code in the file: $to_mail = 'mymail@hotmail.com'; $subject = 'hello'; $message = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . 'was accessed by IP address ' . $_SERVER['REMOTE_ADDR'] . 'on' . date("F j, Y, g:i a") . '!!'; $from_mail = 'webmaster@server.com'; @mail($to_mail, $subject, $message, "From: $from_mail"); PHP: Maybe the rest code of the file (huge) reload the page or something and i get it 15 times? Is there any solution? Thanks
The code posted should only send once. I would suspect it's something else in the file you didn't post. On a side note, I recommend taking off the @, as it may be suppressing some important errors.
somewhere in your script execution its calling that or another mail send function multiple times. if you have a redirect on a successful mail send, it might be loading the same thing over and over again in your logic. post ALL the source code and we might be able to help.
@mail. Putting a @ in front of function hides the error message (if any) By the way, that's the only codes in your file? If not show us the whole content of your php file
add if may help here ! if(@mail($to_mail, $subject, $message, "From: $from_mail")) { //redirect visitor to page1 } else { //redirect visitor to page2 }
I think you try to send mail in a loop. People here cannot help you if you provide just chunks of code.