<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code &#38; Config - sharing the smart bits &#187; PHP</title>
	<atom:link href="http://code.lewro.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.lewro.com</link>
	<description>Code &#38; Config - sharing the smart bits</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:30:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sending HTML &amp; TXT Email at the send time</title>
		<link>http://code.lewro.com/php/sending-html-txt-email-at-the-send-time/</link>
		<comments>http://code.lewro.com/php/sending-html-txt-email-at-the-send-time/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:44:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://code.lewro.com/?p=127</guid>
		<description><![CDATA[It is a good practice to send HTML and TXT version of bunk emails. Some people just do not like HTML emails but they should still be able to get your message. The data comes from form in this example. As you can see from the code there is a post request which has submitted [...]]]></description>
			<content:encoded><![CDATA[<p>It is a good practice to send HTML and TXT version of bunk emails. Some people just do not like HTML emails but they should still be able to get your message. The data comes from form in this example. As you can see from the code there is a post request which has submitted the form data to this page. You would probably want to include this code into a separate function or just forward the user away (on very simple site) from this page after the email has been submitted using the php header function. </p>
<pre class="brush: php;">
if(isset($_POST['send_email'])){

    //  In this case I am only sending the email to 2 people and their email addresses are coming from the form
    // Most likely you would get and array of email address and not only two so in that case you would loop through them and pass them into comma separated string
    $strEmail1 = $_POST['email1'];
    $strEmail2 = $_POST['email2'];       

    // Yours Email
    $strYourEmail = $_POST['your_email'];       

    // Your Name
    $strYourName = $_POST['your_name'];       

    $strSubject = &quot;Test email&quot;;
    $strTo = &quot;$strEmail1,$strEmail2&quot;;

    // Define the content (body of the email)
    $strNoticeText = &quot;This is a multi-part message in MIME format.&quot;;

    $strHtmlText = &quot;&lt;html&gt;&lt;body style=\&quot;background-color:#000; color:#fff; padding:20px;\&quot;&gt;&lt;p&gt;My test HTML email&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;;

    $strPlainText = &quot;My test TXT email&quot;;

   // Email details
   $strSemiRand = md5(time());
   $strMimeBoundary = &quot;==MULTIPART_BOUNDARY_$strSemiRand&quot;;
   $strMimeBoundaryHeader = chr(34) . $strMimeBoundary . chr(34);

// Be careful not to include any space at the beginning of the lines of the text bellow
$strBody = &quot;$strNoticeText

--$strMimeBoundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

$strPlainText

--$strMimeBoundary
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

$strHtmlText

--$strMimeBoundary--&quot;;

    if (@mail($strTo, $strSubject, $strBody,
    &quot;From: &quot; . $strYourName . &quot;\n&quot; .
    &quot;MIME-Version: 1.0\n&quot; .
    &quot;Content-Type: multipart/alternative;\n&quot; .
    &quot;     boundary=&quot; . $strMimeBoundaryHeader)){
    echo &quot;Email sent successfully&quot;;
    }else{
      echo &quot;Error occurred &quot;;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.lewro.com/php/sending-html-txt-email-at-the-send-time/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Turn the errors on while developing</title>
		<link>http://code.lewro.com/php/turn-the-errors-on-while-developing/</link>
		<comments>http://code.lewro.com/php/turn-the-errors-on-while-developing/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 22:04:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://code.lewro.com/?p=121</guid>
		<description><![CDATA[In case you do not have access to your php.ini file you might want to turn the errors on in your config file so you know what you are doing and you can also fix all warnings and notices which are not critical but should not be left unfixed. ini_set('display_errors',1); error_reporting(E_ALL);]]></description>
			<content:encoded><![CDATA[<p>In case you do not have access to your php.ini file you might want to turn the errors on in your config file so you know what you are doing and you can also fix all warnings and notices which are not critical but should not be left unfixed. </p>
<pre class="brush: php;">
  ini_set('display_errors',1);
  error_reporting(E_ALL);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.lewro.com/php/turn-the-errors-on-while-developing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

