<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Mail with Phpmailer</title>
	<link>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/</link>
	<description>web application development with popular technologies</description>
	<pubDate>Wed, 20 Aug 2008 10:12:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: used cars</title>
		<link>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-58266</link>
		<pubDate>Fri, 03 Aug 2007 11:26:51 +0000</pubDate>
		<guid>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-58266</guid>
					<description>nice tutorial,is this support all type of lanuages, mean for non english character unicode. thanks</description>
		<content:encoded><![CDATA[<p>nice tutorial,is this support all type of lanuages, mean for non english character unicode. thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Your Question Here &#187; ramasruthi</title>
		<link>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-104</link>
		<pubDate>Wed, 03 May 2006 02:47:12 +0000</pubDate>
		<guid>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-104</guid>
					<description>[...] Mail with Phpmailer [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Mail with Phpmailer [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cameron Manderson</title>
		<link>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-51</link>
		<pubDate>Wed, 12 Apr 2006 01:11:40 +0000</pubDate>
		<guid>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-51</guid>
					<description>For those of you familiar to MVC framework, the configurations can be managed through your struts/phpmvc config. You could create a MailerPlugin which allows you to accept XML configurations for your particular site. Then you can use various param-set for each default for the email you want. From here you can get your Application Server to generate you a new email through $mailPlugin-&gt;getDefaultMail(). This way your configuration is centralised to an XML document and later you can easily change your implementation of the object that is returned; you may start with a simple PHPMail and later upgrade to a MyMail instance (like above). You application would therefore not need to worry about what correct type of instance to use as all mail creation is centralised to your plugin configuration, and all email code does not need to be changed if an upgrade to your email objects occur.</description>
		<content:encoded><![CDATA[<p>For those of you familiar to MVC framework, the configurations can be managed through your struts/phpmvc config. You could create a MailerPlugin which allows you to accept XML configurations for your particular site. Then you can use various param-set for each default for the email you want. From here you can get your Application Server to generate you a new email through $mailPlugin->getDefaultMail(). This way your configuration is centralised to an XML document and later you can easily change your implementation of the object that is returned; you may start with a simple PHPMail and later upgrade to a MyMail instance (like above). You application would therefore not need to worry about what correct type of instance to use as all mail creation is centralised to your plugin configuration, and all email code does not need to be changed if an upgrade to your email objects occur.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Richard Lee</title>
		<link>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-50</link>
		<pubDate>Tue, 11 Apr 2006 23:09:37 +0000</pubDate>
		<guid>http://www.melbournechapter.net/wordpress/programming-languages/php/cman/2006/04/11/mail-with-phpmailer/#comment-50</guid>
					<description>If your in the habit of using a configuration file and customising classes it's quite easy to do with PHPMailer!

Here's what I do:

SETUP A CONFIGURATION FILE
&lt;pre&gt;&#60; ?php&lt;br /&gt;
&#160;&lt;br /&gt;
// Site configuration settings&lt;br /&gt;
&#46;..&lt;br /&gt;
&#46;..&lt;br /&gt;
&#46;..&lt;br /&gt;
// Email Settings (For PHPMailer)&lt;br /&gt;
define(&#039;EMAIL_FROM_NAME&#039;, &#039;Webmaster&#039; ); // from email name&lt;br /&gt;
define(&#039;EMAIL_FROM_ADDRESS&#039;, &#039;webmaster@mywebsite.com&#039;); // from email address&lt;br /&gt;
// Do we need to relay to a different server???&lt;br /&gt;
// -&#62; Provide option to use external mail server.&lt;br /&gt;
define(&#039;SMTP_MODE&#039;, &#039;disabled&#039;); // enabled or disabled&lt;br /&gt;
define(&#039;SMTP_HOST&#039;, &#039;&#039;);&lt;br /&gt;
define(&#039;SMTP_PORT&#039;, &#039;&#039;);&lt;br /&gt;
define(&#039;SMTP_USERNAME&#039;, &#039;&#039;);&lt;br /&gt;
?&#62;&lt;/pre&gt;
CREATE A CUSTOM CLASS
&lt;pre&gt;require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/lib/phpmailer/class.phpmailer.php&#039;);&lt;br /&gt;
&#160;&lt;br /&gt;
class MyMailer extends PHPMailer&lt;br /&gt;
{&lt;br /&gt;
var $priority = 3;&lt;br /&gt;
var $to_name;&lt;br /&gt;
var $to_email;&lt;br /&gt;
var $From = null;&lt;br /&gt;
var $FromName = null;&lt;br /&gt;
var $Sender = null;&lt;br /&gt;
&#160;&lt;br /&gt;
function MyMailer()&lt;br /&gt;
{&lt;br /&gt;
&#160;&lt;br /&gt;
if(defined(&#039;SMTP_MODE&#039;) &#38;&#38; SMTP_MODE == &#039;enabled&#039;)&lt;br /&gt;
{&lt;br /&gt;
$this-&#62;Host = SMTP_HOST;&lt;br /&gt;
$this-&#62;Port = SMTP_PORT;&lt;br /&gt;
if(defined(&#039;SMTP_USERNAME&#039;) &#38;&#38; !empty(SMTP_USERNAME))&lt;br /&gt;
{&lt;br /&gt;
$this-&#62;SMTPAuth  = true;&lt;br /&gt;
$this-&#62;Username  = SMTP_USERNAME;&lt;br /&gt;
$this-&#62;Password  =  SMTP_PASSWORD;&lt;br /&gt;
}&lt;br /&gt;
$this-&#62;Mailer = &#34;smtp&#34;;&lt;br /&gt;
}&lt;br /&gt;
if(!$this-&#62;From) {&lt;br /&gt;
$this-&#62;From = EMAIL_FROM_ADDRESS;&lt;br /&gt;
}&lt;br /&gt;
if(!$this-&#62;FromName) {&lt;br /&gt;
$this-&#62; FromName = EMAIL_FROM_NAME;&lt;br /&gt;
}&lt;br /&gt;
if(!$this-&#62;Sender) {&lt;br /&gt;
$this-&#62;Sender = EMAIL_FROM_ADDRESS;&lt;br /&gt;
}&lt;br /&gt;
$this-&#62;Priority = $this-&#62;priority;&lt;br /&gt;
}//end constructor&lt;br /&gt;
} //end class&lt;br /&gt;
?&#62;&lt;/pre&gt;
IN USE:
&lt;pre&gt;&#60; ?php&lt;br /&gt;
&#160;&lt;br /&gt;
// Include site config&lt;br /&gt;
require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/config.php&#039;);&lt;br /&gt;
&#160;&lt;br /&gt;
// Include the MyMail class&lt;br /&gt;
require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/lib/MyMailer.php&#039;);&lt;br /&gt;
&#160;&lt;br /&gt;
// Instantiate the class&lt;br /&gt;
$mailer = new MyMailer();&lt;br /&gt;
&#160;&lt;br /&gt;
// Set the subject&lt;br /&gt;
$mailer-&#62;Subject = &#039;This is the subject&#039;;&lt;br /&gt;
&#160;&lt;br /&gt;
// Body&lt;br /&gt;
$mailer-&#62;Body = &#039;This is the body&#039;;&lt;br /&gt;
&#160;&lt;br /&gt;
// Add an address to send to.&lt;br /&gt;
$mailer-&#62;AddAddress(&#039;foo@bar.com.au&#039;, &#039;Foo Bar&#039;);&lt;br /&gt;
&#160;&lt;br /&gt;
if(!$mailer-&#62;Send())&lt;br /&gt;
{&lt;br /&gt;
echo &#039;ERROR: Unable to send email&#039;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
echo &#039;SUCCESS: Mail sent!&#039;;&lt;br /&gt;
}&lt;br /&gt;
// Clear all addresses and attachments ready for next email&lt;br /&gt;
$mailer-&#62;ClearAddresses();&lt;br /&gt;
$mailer-&#62;ClearAttachments();&lt;br /&gt;
?&#62;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>If your in the habit of using a configuration file and customising classes it&#8217;s quite easy to do with PHPMailer!</p>
<p>Here&#8217;s what I do:</p>
<p>SETUP A CONFIGURATION FILE</p>
<pre>&lt; ?php
&nbsp;
// Site configuration settings
&#46;..
&#46;..
&#46;..
// Email Settings (For PHPMailer)
define(&#039;EMAIL_FROM_NAME&#039;, &#039;Webmaster&#039; ); // from email name
define(&#039;EMAIL_FROM_ADDRESS&#039;, &#039;webmaster@mywebsite.com&#039;); // from email address
// Do we need to relay to a different server???
// -&gt; Provide option to use external mail server.
define(&#039;SMTP_MODE&#039;, &#039;disabled&#039;); // enabled or disabled
define(&#039;SMTP_HOST&#039;, &#039;&#039;);
define(&#039;SMTP_PORT&#039;, &#039;&#039;);
define(&#039;SMTP_USERNAME&#039;, &#039;&#039;);
?&gt;</pre>
<p>CREATE A CUSTOM CLASS</p>
<pre>require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/lib/phpmailer/class.phpmailer.php&#039;);
&nbsp;
class MyMailer extends PHPMailer
{
var $priority = 3;
var $to_name;
var $to_email;
var $From = null;
var $FromName = null;
var $Sender = null;
&nbsp;
function MyMailer()
{
&nbsp;
if(defined(&#039;SMTP_MODE&#039;) &amp;&amp; SMTP_MODE == &#039;enabled&#039;)
{
$this-&gt;Host = SMTP_HOST;
$this-&gt;Port = SMTP_PORT;
if(defined(&#039;SMTP_USERNAME&#039;) &amp;&amp; !empty(SMTP_USERNAME))
{
$this-&gt;SMTPAuth  = true;
$this-&gt;Username  = SMTP_USERNAME;
$this-&gt;Password  =  SMTP_PASSWORD;
}
$this-&gt;Mailer = &quot;smtp&quot;;
}
if(!$this-&gt;From) {
$this-&gt;From = EMAIL_FROM_ADDRESS;
}
if(!$this-&gt;FromName) {
$this-&gt; FromName = EMAIL_FROM_NAME;
}
if(!$this-&gt;Sender) {
$this-&gt;Sender = EMAIL_FROM_ADDRESS;
}
$this-&gt;Priority = $this-&gt;priority;
}//end constructor
} //end class
?&gt;</pre>
<p>IN USE:</p>
<pre>&lt; ?php
&nbsp;
// Include site config
require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/config.php&#039;);
&nbsp;
// Include the MyMail class
require_once($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/lib/MyMailer.php&#039;);
&nbsp;
// Instantiate the class
$mailer = new MyMailer();
&nbsp;
// Set the subject
$mailer-&gt;Subject = &#039;This is the subject&#039;;
&nbsp;
// Body
$mailer-&gt;Body = &#039;This is the body&#039;;
&nbsp;
// Add an address to send to.
$mailer-&gt;AddAddress(&#039;foo@bar.com.au&#039;, &#039;Foo Bar&#039;);
&nbsp;
if(!$mailer-&gt;Send())
{
echo &#039;ERROR: Unable to send email&#039;;
}
else
{
echo &#039;SUCCESS: Mail sent!&#039;;
}
// Clear all addresses and attachments ready for next email
$mailer-&gt;ClearAddresses();
$mailer-&gt;ClearAttachments();
?&gt;</pre>
]]></content:encoded>
				</item>
</channel>
</rss>
