Reputation: 629
I'm using the PHP Mail function to send an email and the message has several lines which I've delimited with \r\n, however when the email arrives it contains \r\n in the message instead of starting each row on a new line.
$subject = 'Activation';
$message = 'ActivationCode=' . $activationcode . '\r\nUserLimit=' . $row['userlimit'] . '\r\nCanNetwork=' . $row['canrunonnetwork'];
$headers = 'From: [email protected]';
mail('[email protected]', $subject, $message, $headers);
When the email arrives it looks like this:
ActivationCode=1234\r\nUserLimit=4\r\nCanNetwork=-1
whereas I'd expected it to look like this:
ActivationCode=1234
UserLimit=4
CanNetwork=-1
Upvotes: 0
Views: 127
Reputation: 10202
You should use double ("
) quotes instead if single ones. Variables and line endings etc. don't get expanded in single quotes.
So you code should be:
message = "ActivationCode=" . $activationcode . "\r\nUserLimit= ...etc.";
Upvotes: 0
Reputation: 57729
Change your string delimiter to double quotes.
In PHP strings delimited with '
are literal, strings delimited with "
are interpreted.
So these are equal:
'\r\n' === "\\r\\n"; // true
Upvotes: 3