jiveturkey Posted August 29, 2008 Share Posted August 29, 2008 Hello All I've had this script working on my website for a couple of year but the server has been upgraded to PHP5 and I can on longer send emails. Any body got any idea why this should be This code (below ) used as a test says the email has been sent but nothing appears, the SMTP value on the PHP info is localhost <?php //phpinfo(); //define the receiver of the email $to = 'myemail@gmail.com'; //define the subject of the email $subject = 'Test email'; //define the message to be sent. Each line should be separated with \n $message = "Hello World!\n\nThis is my first mail."; //define the headers we want passed. Note that they are separated with \r\n $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com"; //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?> Here is the code from my page <?php # Script 3.13 - register.php if (isset($_POST['submit'])) { // Handle the form. $message2 = NULL; //empty new variable. $subject = 'Email From Gallery Website'; // Subject. $emailadd = 'myemail@gmail.com';//The email will be sent here. $url = 'thankyou.php'; // Check for a name. if (strlen($_POST['name']) > 0) {$name = TRUE;} else {$name = FALSE;$message2 .= '<p>You forgot to enter your name!</p>';} // Check for a username. if (strlen($_POST['email']) > 0) {$email = TRUE;} else {$email = FALSE;$message2 .= '<p>You forgot to enter your user name!</p>';} // Check for an email address. if (strlen($_POST['message']) > 0) {$message = TRUE;} else {$message = FALSE;$message2 .= '<p>You forgot to enter your email address!</p>';} if ($name && $email && $message) { // If everything's okay. $messageproper = "Name of sender: {$_POST['name']}\n" . "Email of sender: {$_POST['email']}\n" . "Message -------------\n\n" . $_POST['message'] . "\n\n------------------" ; mail($emailadd, $subject, $messageproper, "From: {$_POST['email']}"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; } else { $message2 .= '<p>Please try again.</p>';}}?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <?php if (isset($message2)) {echo '<div id="cnt-mis">', $message2, '</div>';}?> <div class="cnt-inn"><fieldset><legend>Your Details and Message</legend> <div><label for="name">Name:</label><input type="text" name="name" id="name" tabindex="1" /></div> <div><label for="email">Email Address:</label><input type="text" name="email" id="email" tabindex="2" /></div> <div><label for="message">Message:</label><textarea id="message" name="message" tabindex="2"></textarea></div> <input type="submit" id="submit" name="submit" value="Submit" tabindex="4" /></fieldset></div> </form> Any help appreciated Jason Quote Link to comment https://forums.phpfreaks.com/topic/121835-php-mail-suddenly-not-working/ Share on other sites More sharing options...
JonnoTheDev Posted August 29, 2008 Share Posted August 29, 2008 Check the server maillogs after running the script. Is the mail server service started i.e. using sendmail: > service sendmail start Quote Link to comment https://forums.phpfreaks.com/topic/121835-php-mail-suddenly-not-working/#findComment-628569 Share on other sites More sharing options...
jiveturkey Posted August 29, 2008 Author Share Posted August 29, 2008 Thanks got this working now, needed an extra parameter as it was a linux server J Quote Link to comment https://forums.phpfreaks.com/topic/121835-php-mail-suddenly-not-working/#findComment-628678 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.