Author Topic: mail() not working?  (Read 7255 times)

0 Members and 1 Guest are viewing this topic.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
mail() not working?
« on: November 02, 2012, 02:13:45 pm »
I am using this code for an email form processor:

Code: [Select]
<?PHP
//security function
function IsInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)');
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
     } else {
return false;
     }
}

//Get form entries
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$description = $_POST['job-description'];
$contact_method = $_POST['contact-method'];

//security
if(IsInjected($email)) {
echo "Bad email value!";
exit;
}

//Compose email
$email_from = <valid address>;
$email_subject = "TopPage Design form submission: quotes.html";
$email_body = "*** FORM SUBMISSION *** \n
name: " . $name . "\n
email: " . $email . "\n
phone: " . $phone . "\n
description: " . $description . "\n
contact method: " . $contact_method . "\n
*** END OF EMAIL ***";

//Send email
$to = <valid address>;
$headers = "From" . $email_from . "\r\n";
$headers .= "Reply-To:" . $email . "\r\n";

//send
mail($to, $email_subject, $email_body, $headers);
//success
echo("success.");
?>


But for some reason I don't receive the email, even though i get the success message. Am I doing something wrong?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: mail() not working?
« Reply #1 on: November 02, 2012, 02:23:48 pm »
may your mail settings are incorrect in your php.ini, i can't help you much there, sorry
EDIT: just noticed for the headders:
"From: My Secret name <[email protected]>\r\n"
« Last Edit: November 02, 2012, 02:28:00 pm by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: mail() not working?
« Reply #2 on: November 02, 2012, 02:32:10 pm »
may your mail settings are incorrect in your php.ini, i can't help you much there, sorry
EDIT: just noticed for the headders:
"From: My Secret name <[email protected]>\r\n"

Well, its on juju's server so idk...

also, what do you mean about the headers?
« Last Edit: November 02, 2012, 02:32:44 pm by flyingfisch »



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: mail() not working?
« Reply #3 on: November 02, 2012, 02:33:17 pm »
you probably need a 57o9.org email then, let juju do the work for you :P

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: mail() not working?
« Reply #4 on: November 02, 2012, 02:33:59 pm »
you probably need a 57o9.org email then, let juju do the work for you :P

Oh, it won't work for any address?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: mail() not working?
« Reply #5 on: November 02, 2012, 02:45:01 pm »
Mail might be disabled in the php.ini. I would ask Juju if he enabled it.
/e

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: mail() not working?
« Reply #6 on: November 02, 2012, 02:45:14 pm »
It should work without an email account.
You could try if you can send an email using the 'mail' binary.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: mail() not working?
« Reply #7 on: November 02, 2012, 02:46:33 pm »
Yeah, probably a misconfigured php.ini. Might look into this.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: mail() not working?
« Reply #8 on: November 02, 2012, 02:48:51 pm »
Yeah, probably a misconfigured php.ini. Might look into this.

OK, so what should i do in the meantime?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: mail() not working?
« Reply #9 on: November 02, 2012, 02:49:48 pm »
You could execute the 'mail' binary from php :P

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: mail() not working?
« Reply #10 on: November 02, 2012, 02:50:53 pm »
You could execute the 'mail' binary from php :P

I'm not real knowledgeable with PHP. how would i do that? Thanks. :)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: mail() not working?
« Reply #11 on: November 02, 2012, 02:58:53 pm »
It is now fixed. I think I messed it up when I tried setting up email accounts...

The problem was that I uninstalled sendmail in favor of postfix (they conflict each other), thus breaking everthing.
« Last Edit: November 02, 2012, 02:59:33 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: mail() not working?
« Reply #12 on: November 02, 2012, 03:09:35 pm »
/e

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: mail() not working?
« Reply #13 on: November 02, 2012, 03:18:19 pm »
The mail binary wouldn't work without sendmail properly installed anyway, it is now.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: mail() not working?
« Reply #14 on: November 02, 2012, 03:24:17 pm »
works now, thanks juju :)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0