Jump to content

php headers not working with email sending


satbir

Recommended Posts

I have 3 pages. form for sending email is send-mail.php ..... the coding of sending email is in email.php and then thanks.php and at last redirects to main page of website.

 

on click on button in send-mail.php...... page the coding of sending email is working well but headers not working. after sending email page is not redirecting to thanks.php and not redirecting to main page of website.

...

send-mail.php

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); ob_start(); ?>

<button class="btn btn-default" name="submit"> --> Send --> </button>

email.php

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); ob_start(); ?>

    $headers .= "To: $to" . "\r\n";
    $headers .= "From: $email" . "\r\n";
    $headers .= "Cc: $cc" . "\r\n";
    $headers .= "Bcc: $bcc" . "\r\n";

    mail($to,$subject,$message,$headers);
    header('Location:thanks.php');

thanks.php

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); ob_start(); ?>


<?php header("Location:refresh:3;url=http://www.myWebsite.com"); ?>
Link to comment
Share on other sites

What are you seeing on the screen when the mail has been sent and no redirect happens? Or more importantly, what does the page source look like?

 

The code looks strange, to say the least. Are the missing PHP tags around the mail code a copy-and-paste error? Why are you printing error messages on the screen? This is a terrible idea on a public site, and it will indeed break header() calls. And why do you use output buffering?

Edited by Jacques1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.