Does anyone know how to break the email message up into separate lines witihin a php script?
Currently, I've tried below, and it does not work.
Code: Select all
// Send Email notification to let users know a new purchase request has been added to database
$alternate="user1@company.com";
$Email_Date=date('F d, Y');
// Credentials for notification email
$command = "sendEmail";
$from = "-f purchasing@company.com";
$to = $alternate;
$subject = "-u New Purchase Request Alert";
// These lines are the body of the email
$line1 = "A new purchase request has been generated by $Requestor on $Email_Date at $Req_Time.";
$line2 = "This is more information on Line 2.";
$line3 = "This is more information on Line 3.";
$body = $line1 . PHP_EOL . $line2 . PHP_EOL . $line3;
// Mail server and credentials
$server = "-s server.com";
$username = "-xu username@company.com";
$password = "-xp password";
// Concatenate all variables to create sendEmail executable command
$cmd = $command." ".$from." "."-t"." " .$to." ".$subject. " "."-m"." ".$body." ".$server." ".$username." ".$password;
// Execute sendEmail command
echo exec ($cmd);
When I don't try to break the lines (PHP_EOL, or other methods like /r/n, /n) it works fine.
What is the correct code here?