I am sending an email via CodeIgniter's email->send(). I have come across an anomaly that I cannot figure out.
"\r\n" is not working in a certain section of the email. However if I switch "\r\n" to "\r\n\r\n" it works. By works I mean, it adds the 2 line breaks expected.
The problem area is at the bottom.
$order = $this->ordersclass->getOrder( $order_id );
$quantity = $order['no_codes'];
$client = $this->clientclass->getClient( $order['client_id'] );
$multi_d = $this->session->userdata('multi-use-codes-d');
$multi_t = $this->session->userdata('multi-use-codes-t');
$this->load->library('email');
$to = $client['client_email'];
$subject = 'Personal Resiliency Builder Order';
$from = 'accounts@resiliencybuilder.com.au';
$message = "TAX INVOICE\r\n\r\n";
$message .= "Client Name: ". $client['client_name']."\r\n";
$message .= "Invoice Number: ".$order['order_id']."\r\n";
$message .= "Invoice Date: ".$order['order_timestamp']."\r\n\r\n";
$message .= "TOTAL AMOUNT PAYABLE: $".number_format($order['order_amount'],2)."\r\n";
$message .= "GST ON SERVICES: $".number_format(($order['order_amount']/110)*10,2)."\r\n\r\n";
$message .= "ACCOUNT PAID IN FULL VIA CREDIT CARD\r\n\r\n";
$message .= "=============================================================\r\n";
$message .= "DESCRIPTION OF SERVICES\r\n\r\n";
$message .= "Code List Name: ".$this->session->userdata('codelistname') . "\r\n";
$message .= "Quantity: ".$quantity ."\r\n";
$message .= "Single-use Developmental Reports Purchased: ".$order['no_codes_d']."\r\n";
$message .= "Single-use Thriving Reports Purchased: ".$order['no_codes_t']."\r\n";
The last 2 $message
variables are the problem.
The email looks like this:
TOTAL AMOUNT PAYABLE: $1,771.00
GST ON SERVICES: $161.00
ACCOUNT PAID IN FULL VIA CREDIT CARD
=============================================================
DESCRIPTION OF SERVICES
Code List Name: fggdgfdgfd
Quantity: 12
Single-use Developmental Reports Purchased: 7 Single-use Thriving Reports Purchased: 5
Multi-use Developmental Reports Purchased: 5 Multi-use Thriving Reports Purchased: 5
SOLVED. Now looking for the understanding behind it.
After many tests, the formula for failure is: Failure = X + Y:
Failure = X character length + spaces.
In addition, it seams this problem occurs with Microsoft outlook 20xx, but not with hotmail or gmail.
Example:
$message .= "Single-use: Developmental Reports : ddddd\r\n"; ////// fail - length 41
$message .= "Single-use: DevelopmentaldReportsd:dddddd\r\n"; /// fail - length 41
$message .= "Single-use:dDevelopmentaldReportsd:dddddd\r\n"; // pass - length 41
$message .= "Single-use:DevelopmentaldReportsd:dddddddddddddddddddddddddddddd\r\n"; // pass