Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Please, this is php code that i used to send from HTML contact page, it works with out error but only i receive empty email! just the object of email i get and nothing else.
<?php
$email_address = $_POST["email"];
$tel_num = $_POST["tel"];
$first_name = $_POST["f_name"];
$last_name = $_POST["l_name"];
$text_send = $_POST["email_text"];
$to_com = "myemal#gmail.com" ;
$subject = " New eMail" ;
mail ($to_com, $subject, $text_send, " From: " . $email_address . $tel_num . $first_name .$last_name );
echo "Your Massage has been sent" ;
?>
So please i need some help?
Please look at this example from php.net
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
the line endings in the header (\r\n) are very important
Related
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have a PHP simple code which supposed to send an email, but it seems it does not work since I have never received any mail.
Well I have a free free host and domain with CPanel that I have a Webmail feature there, I can send email through that to wherever I want (Yahoomail, Gmail, ..).
I really do not know how to solve it.
Here is my php code:
$to = 'sample#yahoo.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: sample#sample.com' . "\r\n" . 'Reply-To: sample#sample.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);`
My sendmail_path /usr/local/bin/phpsendmail, Path to sendmail /usr/local/bin/phpsendmail, SMTP localhost, smtp_port 25
Try this ...
$to = "somebody#example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster#example.com" . "\r\n" .
"CC: somebodyelse#example.com";
mail($to,$subject,$txt,$headers);
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am using mail() on my site, and the function is working, but the from address is not showing my email address, it is showing name#mailchannels.net
$ito_email = "$inameuser";
$ifrom_email = "info#mywebsite.co.za";
$isubject = "My subject";
$icomment = "Hello $inameuser,\r\n\r\n"
. " \r\n"
. "Subject: $isubjectnote"
. " \r\n"
. "Notice: $inote"
. " \r\n"
. "\r\n"
. "Many thanks";
//send email
mail($ito_email, "$isubject", $icomment, "From: Support " . $ifrom_email);
Changing
mail($ito_email, "$isubject", $icomment, "From: Support " . $ifrom_email);
to
mail($ito_email, "$isubject", $icomment, "From: Support <" . $ifrom_email . ">");
Should allow you to include a readable name as well as the FROM e-mail address.
EXAMPLE:
$email = "emailfrom#anything.com";
$headers = 'From: ' . $email . '' . "\r\n" . "Content-type: text/html;charset = windows-1250";
$subject = $email . ' - New message';
mail("your email", $subject, "email message", $headers);
$to = 'abc#xyz.com'; $subject = 'the subject';
$message = 'Message';
$headers = 'From: xyz#xyz.com' . "\r\n" .'Reply-To: xyz1#xyz.com' . "\r\n";
mail($to, $subject, $message, $headers);
OR
$headers .= $headers; Concat
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
Here is my code:
<?php
header('Content-type: text/plain; charset=utf-8');
$to = 'example#gmail.com';
$subject = 'Message to the site';
$realname = htmlspecialchars($_POST['realname']);
$email = htmlspecialchars($_POST['email']);
$msg = htmlspecialchars($_POST['msg']);
$headers = 'From: example#gmail.com' . "\r\n" .
'Reply-To: example#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $msg, $headers) or die("Error!");
echo 'Thank you! :)';
?>
Could somebody explaing me - why this code does not work properly?
I meant that, when I click button submit, it send the email, but I could not include $msg in it and I don't know why.
Try to add :
$headers .= 'Content-type: text/html';
Add this line under $headers and than check i hope this will work for you...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
The following is the code for "Contact Us" page. Is this wrong code?
When I send messages, do not go to my E-mail !
i want The correct way to write it?
<?php
if(isset($_POST['sendmail'])) {
$to='a#example.com';
if (mail($to,$_POST['name'],$_POST['message'])) {
echo 'is ok';
} else {
echo "Error : Not Send Mail";
}
} else {
echo 'not ok!!!';
}
?>
Try this:
http://php.net/manual/en/function.mail.php
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Customized for your example:
<?php
if(isset($_POST['sendmail'])) {
$to = 'a#outlook.com';
$subject = $_POST['name']; // I do not know if this is your email subject
$message = $_POST['message'];
$headers = 'From: a#outlook.com' . "\r\n" . // This will appear as to who sent the email
'Reply-To: a#outlook.com' . "\r\n" . // This will appear as to who to send the replies
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
echo 'is ok';
} else {
echo "Error : Not Send Mail";
}
} else {
echo 'not ok!!!';
}
?>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to make emails sent via contact form on my website to appear as being sent from user's mailbox (eg. user specified his email in contact form as 'john1233#gmail.com' - i want this email to be seen as sent from him directly, with proper reply option).
I tried to modify this script on my own, with no success :( I am not very proficient with php, so any help will be much appreciated!!
Here is the script I used:
<?php
if(isset($_POST['email'])) {
$email_to = "my email";
$email_subject = "mail subject";
// validation here
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
// error messages here
$error_message = "";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .='my html code'
;
// create email headers
$headers = 'From: '.$email_from."\r\n".
$headers = "MIME-Version: 1.0\r\n";
$headers = "Content-type: text/html; charset=utf-8\r\n";
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
It should be:
$headers = 'From: '.$email_from."\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/html; charset=utf-8\r\n" .
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();