PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
FenixDarkclaw
Forum Newbie
Posts: 2 Joined: Tue Jun 14, 2005 9:56 am
Post
by FenixDarkclaw » Tue Jun 14, 2005 10:01 am
I have the follow code, which is suppose to take data from a form and send it in an email. Everything seems to work, the form submits, the page runs with no errors and even my little bit of error checking says the mail was sent. But the mail is never received. I've used formmail.pl and other prewritten script for this as well and I have the exact same problem. Any ideas?
Code: Select all
<?php
$message = '';
echo "POST/GET Variables: <br>";
foreach ($_POST as $key => $val)
if ($key != "recipient" && $key != "redirect" && $key != "print_config" && $key != "required" && $key != "Submit")
$message .= "$val<br>";
$header = "From: ";
$header .= $email;
$header2 = "-f";
$header2 .= $email;
echo "$message";
$ok = mail($recipient, $subject, $message, $header, $header2);
if ($ok) {
echo "Mail succesfully sent to: ".$recipient;
} else {
echo "Error: Unable to send mail to: ".$recipient;
}
?>
harrison
Forum Commoner
Posts: 30 Joined: Thu Jun 09, 2005 12:23 am
Post
by harrison » Tue Jun 14, 2005 8:11 pm
Did you correctly configure you
php.ini regarding
SMTP server and port?
This section is located after a bunch of extensions config:
Code: Select all
їmail function]
; For Win32 only.
SMTP=localhost
smtp_port=25
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Tue Jun 14, 2005 9:37 pm
Where's your server? Is it a home server, a shared hosting server?
FenixDarkclaw
Forum Newbie
Posts: 2 Joined: Tue Jun 14, 2005 9:56 am
Post
by FenixDarkclaw » Wed Jun 15, 2005 7:07 am
My php.ini looks like this:
Code: Select all
їmail function]
; For Win32 only.
SMTP=localhost
smtp_port=25
And my server is the server at my job (School server) which I have little knowledge of how it is set up unfortunatly.
This is quite the confusing development, and I apprieciate all the help.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Wed Jun 15, 2005 7:19 am
At least two possibilities
1. SMTP isn't installed or running on localhost (it could be provided by an ISP).
2. The mail is being filtered as junk by the recipient
Try searching by the way. This has been asked umpteen times here before
Last edited by
Chris Corbyn on Wed Jun 15, 2005 7:20 am, edited 1 time in total.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Wed Jun 15, 2005 7:20 am
one thing that catches my eye is
Code: Select all
foreach ($_POST as $key => $val)
if ($key != "e;recipient"e; && $key != "e;redirect"e; && $key != "e;print_config"e; && $key != "e;required"e; && $key != "e;Submit"e;)
$message .= "e;$val<br>"e;;
the lack of brackets there but its still legal and all just wondering what exactly you want where cause they style gets confusing fast.
maybe just try doing somtin real simple like
Code: Select all
mail('myemail@server.com', 'did you get this email?', 'I HOPE YOU DID!');
and see if you end up getting it
Syranide
Forum Contributor
Posts: 281 Joined: Fri May 20, 2005 3:16 pm
Location: Sweden
Post
by Syranide » Wed Jun 15, 2005 7:50 am
that last field will likely set you back as it isn't a valid SMTP-header.
EDIT: 'I HOPE YOU DID!'