asked on
$email_from = 'webadminmailid@hotmail.com';
$email_message ='
<html>
<body>
message body here
</body>
</html>
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= ' From: '.'mymailid@hotmail.com'."\r\n" .
'Reply-To: '.$email_from.'\r\n' .
'X-Mailer: PHP/' . 'phpversion()';
@mail($email,'Thank-you', $email_message, $headers);
$headers1 = '';
$emailto = "adminmailid@gmail.com";
$email_from1 = $_POST['email'];
$email_message1 = "A new user having following details has registered on ".date("Y-m-d")." at ".date("H:i")."\n\n";
foreach($_POST as $field_name => $field_value) {
$email_message1.= $field_name.": ".$field_value."\n\n";
}
$headers1 = 'MIME-Version: 1.0' . "\r\n";
$headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers1 .= 'From: '.$email_from1."\r\n" .
'Reply-To: '.$email_from1."\r\n" .
'X-Mailer: PHP/' . phpversion();
// send the email
mail($emailto,"New Registration", $email_message1, $headers1) ;
if($mail->ErrorInfo) { die($mail->ErrorInfo) ; }
header("location: register-success.php");
ASKER
It is a plain fact that you cannot be using that script to send email, since the script fails with a parse error.Maybe it did have parse error because i posted a part of the code.
In the case of the admin emails, there is not much I can tell you because the content of the message relies on external data and we cannot see that data.I have var_dumped on two variables $messages ($messages consist of data from post values ),$headers they are populated as intended and i can see the values there is nothing wrong in that.
header("location: register-success.php");
run after each email?ASKER
I would post the entire php script once i am on my workstation.That will be very helpful because then we will have the true line numbers and can give some step-by-step directions to help debugging.
ASKER
admin are not recieving email and without email how can you see headersWhat we need to understand is why the admin is not receiving the email. If you put my address in for the admin in your test case, I will be able to see once we get the email to work! I do not need to see the user mail, only the admin email.
ASKER
I will be posting the entire script . Please do let me know what are the other problems besides using generic email id .
You have several problems that I can see in addition to the script being incomplete
ASKER
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
In the case of the admin emails, there is not much I can tell you because the content of the message relies on external data and we cannot see that data. However you can omit this part: if($mail->ErrorInfo) { die($mail->ErrorInfo) ; } because that relies on object-oriented notation, and there are no instances of the mail object in the code. Instead, I would look at the code logic carefully (requires the full script!) and see if there is not some conditional if() structure or similar that is blocking access to the part of the code that sends the admin mail. I would also remove the redirection at the bottom and instead use var_dump() to print out all of the variables involved in the admin mail. Once you see the script logic and the content of the variables you will probably be able to see what's going awry.
See also http://php.net/manual/en/function.mail.php and read it with an eye for detail.
HTH, ~Ray