I am using below php code to send email after collecting user entered email ID (email-box) and content from a textarea(output_textarea) as message.
$to = $_REQUEST['email-box'] ;
$message = $_REQUEST['output_textarea'];
$subject = 'form meta cli script';
$headers = 'From: info#mydomain.com' . "\r\n" .
'Reply-To: me#mydomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
But outlook is removing the line break and on top giving message "Extra Line breaks in this message were removed" How can I keep the line break in outlook?
Related
I have the code below and the redirect works. However when I have the die() command at the bottom the email doesn't get sent. The email goes fine without the die() command.
Is there a way I can stop the php script continuing without stopping the email from working?
$to = 'hello#nospam.com';
$subject = "Test Subject";
$message = "Test Message";
$headers = 'From: robocop#nospam.com' . "\r\n" .
'Reply-To: robocop#nosopam.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header('Location:http://nospam.com/home/bouncer.php');
die();
Try this for testing. I don't think that there are really such problem.
$to = 'hello#nospam.com';
$subject = "Test Subject";
$message = "Test Message";
$headers = 'From: robocop#nospam.com' . "\r\n" .
'Reply-To: robocop#nosopam.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
header('Location:http://nospam.com/home/bouncer.php');
} else {
echo "Fail";
}
die(); // and use for also exit(); for testing
That's very interesting if it is real problem.
I have a problem with sending mail from PHP.
$to = 'admin#****';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#****' . "\r\n".
'Reply-To: webmaster#****' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers)
When I run this simple example script, or basically any tutorial script, I get the following error from hMailServer 554 Rejected - Message containing bare lf's.
I know this is due to a setting in hMailServer, but I don't want to turn off the RFC compliance check, I want to send correctly formatted mails.
Can you help me figure out what's wrong?
I am a PHP novice here. I have a send mail script that looks like this:
$to = 'example#email.com';
$from = 'noreply#email.com';
$subject = 'Test Submission';
$message = 'This is just another test.';
$headers = 'From: example#email.com' . "\r\n" .
// 'Reply-To: example#email.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
This script works fine and sends an e-mail when the page is loaded. The problem is that when I alter the script just enough so that the form is not submitted until the Submit button is clicked then all of a sudden nothing works anymore. Here is the altered code I have been trying to use (and which seems to go right along with what the PHP site suggests):
if(isset($_POST['submit'])){
$to = 'example#email.com';
$from = 'noreply#email.com';
$subject = 'Test Submission';
$message = 'This is just another test.';
$headers = 'From: example#email.com' . "\r\n" .
// 'Reply-To: example#email.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
Make sure your submit button on your form has a NAME attribute. The value of that NAME attribute is what gets sent to the server, so:
<input type="submit" name="btnSubmit" value="Go!">
...would result in this variable and value:
$_POST["btnSubmit"] = "Go!";
...and you would check it like this:
if(isset($_POST["btnSubmit"]))
{
...
}
I use this sample of code to send email from php
<?php
$to = 'nobody#example.com';
$subject = $_POST['subject']; //"the \test subject's";
$message = $_POST['body']; //'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
but when i recieve the email the subject displayed like that
the \\test subject's
How to remove this extra slash ?
Thanks
From http://php.net/manual/en/function.mail.php :
subject
Subject of the email to be sent.
Caution Subject must satisfy ยป RFC 2047.
RFC 2047 : http://www.faqs.org/rfcs/rfc2047.html
Wish it will help you.
Let me start by saying I do not have a lot of programming knowledge. I use a program called PHPRunner to generate most of the php that I do. It is mainly for small office stuff nothing fancy.
My question is:
I have a table that has 6 fields one of them called email. When I go into a record I wanted to put a button called "send notification" that would email the record details to the email address associated with that record.
Any help would be greatly appreciated. I know it is probably out here on the web, possibly searching the wrong way.
You can use the mail function in php. Example from the provided link:
<?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);
?>
For sending email using PHP, use mail() function
http://php.net/manual/en/function.mail.php
Example:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$from = 'webmaster#example.com';
$headers = 'From: '.$from . "\r\n" .
'Reply-To: '.$from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>