blastbum Posted June 14, 2011 Share Posted June 14, 2011 Hi, I'm a noobie and having massive issues with a PHP script that sends an email to a user. The email is in plain text, yet the text is in double-spacing which is very frustrating. I have included the code below for you to examine. If anyone could help me to get the text back to single spacing that would be great. <?php $to = $email; $subject = 'Client Registration - XXXXX XXXXXXXXXXX'; $message = 'Dear '.$first_name.' We recently sent you an email to announce our new website with particular reference to your financial and classing data statements. Our website has information about the XXXX XXXXX, our contact details, including our regional Agents, market and price information, along with your personal financial documents such as Recipient Created Tax Invoices and Classing Data. By providing this information on-line, you will be able to access your personal information relating to business with XXXX more efficiently. However, if you would like to receive your statements via an alternative method, please don’t hesitate to contact us. This email is to confirm that you now have access to the grower section of our new website. Your details are: Your Email: '.$email.' Your Username: '.$username.' Your Password: '.$password.' Please keep these details safe as they provide direct access to your personal information. If you have any questions or issues accessing our site or your information, please contact me directly. Thank you for your business and we hope we can continue our commercial relationship going forward. Yours Sincerely, XXXXXXXX XXXXX / Director XXXX XXXXXXXX Suite XX, Level X, XX Castlereagh Street | Sydney, NSW Australia Tel: +61 2 XXXX XXXX | Mobile: +61 XXX XXX XXX | Fax: +61 2 XXXX XXXX Email: xxxxxxxx Web: xxxxxxxxxx '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n"; $headers .= 'From: XXXX Xxxxxxxxxx <[email protected]>' . "\r\n"; $headers .= 'Reply-To: [email protected]' . "\r\n"; // Mail it if (@mail($to, $subject, $message, $headers)){ $_SESSION['msg'] .= 'Email Sent to the new client.'; } else { $_SESSION['msg'] .= 'Email Failed.'; } ?> And this is how the text of the email turns out: Dear Xxxxxx We recently sent you an email to announce our new website with particular reference to your financial and classing data statements. Our website has information about the XXXX Xxxxx, our contact details, including our regional Agents, market and price information, along with your personal financial documents such as Recipient Created Tax Invoices and Classing Data. By providing this information on-line, you will be able to access your personal information relating to business with XXXX more efficiently. However, if you would like to receive your statements via an alternative method, please don’t hesitate to contact us. This email is to confirm that you now have access to the grower section of our new website. Your details are: Your Email: [email protected] Your Username: testtesting Your Password: testtesting Please keep these details safe as they provide direct access to your personal information. If you have any questions or issues accessing our site or your information, please contact me directly. Thank you for your business and we hope we can continue our commercial relationship going forward. Yours Sincerely, Matthew Bradd Director ECOM Australia Suite 801, Level 8, 15 Castlereagh Street | Sydney, NSW Australia Tel: +61 2 9223 3631 | Mobile: +61 418 635 416 Fax: +61 2 9233 6206 Email: [email protected] Web: http://www.ecomcommodities.com.au/ If you could help me out here and show me how I can remove the double-spacing I would greatly appreciate it. Many thanks, Dan Quote Link to comment https://forums.phpfreaks.com/topic/239333-how-do-i-remove-the-double-spacing-in-the-email-body-text/ Share on other sites More sharing options...
fugix Posted June 14, 2011 Share Posted June 14, 2011 place your message in double quotes and try placing a "\r" on the end of each line Quote Link to comment https://forums.phpfreaks.com/topic/239333-how-do-i-remove-the-double-spacing-in-the-email-body-text/#findComment-1229509 Share on other sites More sharing options...
requinix Posted June 14, 2011 Share Posted June 14, 2011 A simple $message = str_replace("\r\n", "\n", $message); should be enough. Quote Link to comment https://forums.phpfreaks.com/topic/239333-how-do-i-remove-the-double-spacing-in-the-email-body-text/#findComment-1229548 Share on other sites More sharing options...
blastbum Posted June 28, 2011 Author Share Posted June 28, 2011 Hi, It did appear to be working, but I have discovered another issue. The email formatting works fine being sent to my POP mail account, but the line breaks are not happening when the email is sent to my IMAP account. I believe this issue can be resolved if I put HTML into the mail via the PHP script. Can you please tell me how to insert HTML into the PHP script so the HTML appears in the email that is being sent? Thank you once again for your help. It is invaluable. Dan Quote Link to comment https://forums.phpfreaks.com/topic/239333-how-do-i-remove-the-double-spacing-in-the-email-body-text/#findComment-1235891 Share on other sites More sharing options...
requinix Posted June 28, 2011 Share Posted June 28, 2011 Change the Content-type to "text/html" (keep the charset) and put HTML in your $message. Quote Link to comment https://forums.phpfreaks.com/topic/239333-how-do-i-remove-the-double-spacing-in-the-email-body-text/#findComment-1236078 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.