Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

php send mail

Thsi code works fine for sending email if the "From" field is filled in
It does not work at all if the "From" and "CC" field s are filled in
Could someone please explain:

--------------------------------------------------

<?php

session_start();

if ($_POST['email']) {

            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

if ($_POST['cc']) {
            $headers .= "Cc: $_POST[cc]" . "\r\n";
}            

            $email_to = $_POST['email'];
                $subject = "Support Links from TickTockIT";

            $headers .= 'From: Tick Tock IT <info@ticktockit.net>' . "\r\n";            

            ob_start();
                  include('email-content.php');
                  $message = ob_get_contents();
            ob_end_clean();

            mail($email_to, $subject, $message, $headers);

$_SESSION['sent'] = 1;
header('Location: send-email_b.php'); die;
}

?>

---------------------------------------
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

Sorry - still not doing it
Same problem
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the "From" email firld is filled in then the email is sent
If the "From" email field and the "CC" email field are both filled in then nothing is sent
No error message - the script runs and the "your message has been sent" is displayed on my screen
I have attached the full page below
send-email-b.php
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I used your code bbut with my email address
Still the same problem

Could this be a php.ini config issue ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is working now
It looks as if one of the cc email address I was using was not being recognised correctly

Thanks all
I've requested that this question be closed as follows:

Accepted answer: 125 points for Dave Baldwin's comment #a40694106
Assisted answer: 125 points for Dave Baldwin's comment #a40694076
Assisted answer: 125 points for Ray Paseur's comment #a40694098
Assisted answer: 0 points for doctorbill's comment #a40694121
Assisted answer: 125 points for Dave Baldwin's comment #a40694127

for the following reason:

Solution
Solution