-3

this is my code, But i am getting blank mails also. what was the wrong with this? 'success', 'message'=>'Thank you for contact us. As early as possible we will contact you ' );

    $name = @trim(stripslashes($_POST['name'])); 
    $email = @trim(stripslashes($_POST['email'])); 
    $subject = @trim(stripslashes($_POST['subject'])); 
    $message = @trim(stripslashes($_POST['message'])); 

    $email_from = $email;
    $email_to = 'To: <someone@gmail.com>, <anotherone@gmail.com>' . "\r\n";

    $body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

    $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

    echo json_encode($status);
    die;
Hafeef kt
  • 1
  • 1

1 Answers1

1

Please read documentation mail function Here they explained detailedly.

Particularly Example #4 Sending HTML email

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

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
gvgvgvijayan
  • 1,851
  • 18
  • 34
  • thank you vijayan, Now i can add multiple mails, But the thing is when i send a mail i am getting two in my inbox. one is exacttly what i sent, that from the given mail id, And another one from the server its blank all time. how can i stop these blank mails from server? – Hafeef kt Jun 24 '15 at 05:55
  • Post your code please @Hafeefkt – gvgvgvijayan Jun 24 '15 at 07:21
  • i edited the previous code.. please look at top. help me – Hafeef kt Jun 24 '15 at 09:47
  • From the code It is clear that it send only one time. Try to debug the code using xdebug to know how code executes step by step using some good IDE. I'm using netbeans. – gvgvgvijayan Jun 24 '15 at 10:40
  • i dont knw how to do it. am new to php.. can i hav som tips? – Hafeef kt Jun 24 '15 at 11:01
  • 1) http://wiki.netbeans.org/HowToConfigureXDebug 2) https://netbeans.org/kb/docs/php/debugging.html please do as in this two link. You will get some idea. – gvgvgvijayan Jun 24 '15 at 12:09