Hi Folks,Can someone please explain how I can do some basic formatting within a string?I've tried concatenating <br /> tags in quotes and other basic HTML markup all to no avail.The parser just spits it out verbatim as non rendered code.

$remindDates[] = 'Dear ' . $row['firstname'] . ',' . ' This is just to let you know that your Web Hosting account registered with us for the domain: ' . $row['domain'] . ' expires in one month\\'s time on: ' . $row['expireDate'];

I'd like to break this big string onto a new line and maybe bold some words.

Any help appreciated.

cpradio
—
2012-08-10T12:00:00Z —
#2

Is this part of an email or shown on a webpage?If it is part of an email, I am assuming your e-mail is sent in plan text (not HTML), so you will want to use PHP_EOL for line breaks or ."\r\" (double quotes are a necessity for this one)If it is part of a webpage, can you show us how the information gets rendered?

Argent
—
2012-08-10T12:28:56Z —
#3

Sorry, I could have been a little more explicit.I have a php mail script which will catch the array information and send an email (Hosting renewal reminder) using a cron job via the server.

Prior to connecting the mail script I am testing it in Firefox and it renders as per the attached screenshot, but the plan is to ultimately have an email sent.

What is PHP_EOL please?

cpradio
—
2012-08-10T15:34:30Z —
#4

PHP_EOL is a constant that stands for End of Line. It writes the \r\ characters on your behalf thus allowing a new line to be created. When viewing it in a browser, the PHP_EOL will not be visible unless you perform a view source or run the output through nl2br($output);

PHP_EOL is a constant that stands for End of Line. It writes the \r\ characters on your behalf thus allowing a new line to be created.

Just to clarify, the PHP_EOL constant will use the correct set of escape sequences for the architecture it's working on. If this is Windows, then it'll use the \r\ (CR/LF) sequence; however if it's Os x, then only \r (CR) is required, and for Linux only \ (LF) is needed. So it's an abstract constant that allows us to make our code cross-compatible.

ScallioXTX
—
2012-08-11T16:57:47Z —
#8

As said before by default PHP sends email as plain-text. If you want to send html you need to set the correct headers.

Thanks for your reply.Can I just layout my objective in full, as I probably started 'half way up the ladder' with my initial post.I think I have the send mail concept down now, however my ultimate objective is to send individual email reminders to hosting clients based on a MySQL query of 'remindDate' being CURDATE().What I have done so far:I have successfully pulled the required data from the database and output it in the browser.This has resulted in multiple matches. My question is: How do I send individual reminder emails to these matched results?.

Please note: I have commented out the CURDATE() condition at this time to simplify debugging.

Well, you have a few ways you can go about it. 1) you can call the mail() command within your foreach, sending the email to each recipient. or 2) If you have a generic enough message, you can Blind Carbon Copy all recipients and use only 1 mail command

Argent
—
2012-08-12T14:05:45Z —
#11

cpradio said:

Well, you have a few ways you can go about it. 1) you can call the mail() command within your foreach, sending the email to each recipient. or 2) If you have a generic enough message, you can Blind Carbon Copy all recipients and use only 1 mail command

Yes, I'd like it to be personalised rather than generic, can you possibly show me how the code would look calling the mail() command from within the foreach loop?

Few things to note, 1) if testing, DO NOT use $row['to_email_address'], instead hard code an email address so your subscribers do not get your test emails.2) You will need to eventually return the email address from your database for your subscriber, so I just guessed and called it to_email_address

Let me know if you need anything else.

Argent
—
2012-08-12T15:05:30Z —
#13

Thanks for your time, but it didn't work for me - just threw up a blank browser page.

cpradio
—
2012-08-12T15:26:15Z —
#14

well, yes, it would show a blank page, as I didn't output anything, it would send an email if you replaced the variables correctly.