phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] old/squirrelmail/src/phpmailer-1.41/docs faq.html, 1.


From: skwashd
Subject: [Phpgroupware-cvs] old/squirrelmail/src/phpmailer-1.41/docs faq.html, 1.1 extending.html, 1.1 timeoutfix.diff, 1.1
Date: Thu, 5 May 2005 02:56:00 +0200

Update of old/squirrelmail/src/phpmailer-1.41/docs

Added Files:
     Branch: MAIN
            faq.html 
            extending.html 
            timeoutfix.diff 

Log Message:
cvs clean up

====================================================
Index: faq.html
<html>
<head>
<title>phpmailer FAQ</title>
</head>

<body bgcolor="#FFFFFF">

<h2>phpmailer FAQ</h2>

<p>
<b>I'm using the SMTP mailer and I keep on getting a timeout message
well before the X seconds I set it for.  What gives?</b>
<br>
PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout
early.  You can fix this by re-compiling PHP 4.0.4pl1 with this fix:
<a href="timeoutfix.diff">timeoutfix.diff</a>. Otherwise you can wait
for the new PHP release.
</p>

<p>
<b>I am concerned that using include files will take up too much
processing time on my computer.  How can I make it run faster?</b>
<br>
PHP by itself is very fast.  Much faster than ASP or JSP running on
the same type of server.  This is because it has very little overhead compared
to its competitors and it pre-compiles all of
its code before it runs each script (in PHP4).  However, all of
this compiling and re-compiling can take up a lot of valuable
computer resources.  However, there are programs out there that compile
PHP code and store it in memory (or on mmaped files) to reduce the
processing immensely.  Two of these: <a 
href="http://apc.communityconnect.com";>APC
(Alternative PHP Cache)</a> and <a 
href="http://bwcache.bware.it/index.htm";>Afterburner</a>
(<a href="http://www.mm4.de/php4win/mod_php4_win32/";>Win32 download</a>)
are excellent free tools that do just this.  If you have the money
you might also try <a href="http://www.zend.com";>Zend Cache</a>, it is
even faster than the open source varieties.  All of these tools make your
scripts run faster while also reducing the load on your server. I have tried
them myself and they are quite stable too.
</p>


<p>
<b>What mailer gives me the best performance?</b>
<br>
On a single machine the mail() or sendmail mailers give you the best
performance because they do not have the added overhead of SMTP.
If you have you have your mail server on a another machine then
SMTP is your only option, but you do get the benefit of redundant
mail servers.
</p>

<p>
<b>When I try to attach a file with on my server I get a
"Could not find {file} on filesystem error".  Why is this?</b>
<br>
If you are using a Unix machine this is probably because the user
running your web server does not have read access to the directory
in question.  If you are using Windows, then the problem probably is
that you have used single backslashes to denote directories ("\").
A single backslash has a special meaning to PHP so these are not
valid.  Instead use double backslashes ("\\") or a single forward
slash ("/").
</p>

</body>
</html>

====================================================
Index: extending.html
<html>
<head>
<title>Examples using phpmailer</title>
</head>

<body bgcolor="#FFFFFF">

<h2>Examples using phpmailer</h2>

<h3>1. Advanced Example</h3>
<p>

This demonstrates sending out multiple email messages with binary attachments
from a MySQL database with multipart/alternative support.<p>
<table cellpadding="4" border="1" width="80%">
<tr>
<td bgcolor="#CCCCCC">
<pre>
require("class.phpmailer.php");

$mail = new phpmailer();

$mail->From     = "address@hidden";
$mail->FromName = "List manager";
$mail->Host     = "smtp1.site.com;smtp2.site.com";
$mail->Mailer   = "smtp";

@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("my_company");
$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
address@hidden($query);

while ($row = mysql_fetch_array ($result))
{
    // HTML body
    $body  = "Hello &lt;font size=\"4\"&gt;" . $row["full_name"] . 
"&lt;/font&gt;, &lt;p&gt;";
    $body .= "&lt;i&gt;Your&lt;/i&gt; personal photograph to this 
message.&lt;p&gt;";
    $body .= "Sincerely, &lt;br&gt;";
    $body .= "phpmailer List manager";

    // Plain text body (for mail clients that cannot read HTML)
    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
    $text_body .= "Your personal photograph to this message.\n\n";
    $text_body .= "Sincerely, \n";
    $text_body .= "phpmailer List manager";

    $mail->Body    = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress($row["email"], $row["full_name");
    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

    if(!$mail->Send())
        echo "There has been a mail error sending to " . $row["email"] . 
"&lt;br&gt;";

    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();
}
</pre>
</td>
</tr>
</table>
<p>

<h3>2. Extending phpmailer</h3>
<p>

Extending classes with inheritance is one of the most
powerful features of object-oriented
programming.  It allows you to make changes to the
original class for your
own personal use without hacking the original
classes.  Plus, it is very
easy to do. I've provided an example:

<p>
Here's a class that extends the phpmailer class and sets the defaults
for the particular site:<br>
PHP include file: <b>mail.inc.php</b>
<p>

<table cellpadding="4" border="1" width="80%">
<tr>
<td bgcolor="#CCCCCC">
<pre>
require("class.phpmailer.php");

class my_phpmailer extends phpmailer {
    // Set default variables for all new objects
    var $From     = "address@hidden";
    var $FromName = "Mailer";
    var $Host     = "smtp1.site.com;smtp2.site.com";
    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
    var $WordWrap = 75;

    // Replace the default error_handler
    function error_handler($msg) {
        print("My Site Error");
        print("Description:");
        printf("%s", $msg);
        exit;
    }

    // Create an additional function
    function do_something($something) {
        // Place your new code here
    }
}
</td>
</tr>
</table>
<br>

Now here's a normal PHP page in the site, which will have all the defaults set
above:<br>
Normal PHP file: <b>mail_test.php</b>
<p>

<table cellpadding="4" border="1" width="80%">
<tr>
<td bgcolor="#CCCCCC">
<pre>
require("mail.inc.php");

// Instantiate your new class
$mail = new my_phpmailer;

// Now you only need to add the necessary stuff
$mail->AddAddress("address@hidden", "Josh Adams");
$mail->Subject = "Here is the subject";
$mail->Body    = "This is the message body";
$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name

if(!$mail->Send())
{
   echo "There was an error sending the message";
   exit;
}

echo "Message was sent successfully";
</pre>
</td>
</tr>
</table>
</p>

</body>
</html>

====================================================
Index: timeoutfix.diff
*** /usr/local/src/php-4.0.4pl1/ext/standard/fsock.c.old        Mon Mar 26 
13:07:40 2001
--- /usr/local/src/php-4.0.4pl1/ext/standard/fsock.c    Mon Mar 26 13:12:03 2001
***************
*** 559,564 ****
--- 559,565 ----

  static void php_sockread_total(php_sockbuf *sock, size_t maxread)
  {
+         sock->timeout_event = 0;
        while(!sock->eof && TOREAD(sock) < maxread && !sock->timeout_event) {
                php_sockread_internal(sock);
        }
***************
*** 619,624 ****
--- 620,627 ----
        }

        SEARCHCR();
+
+         sock->timeout_event = 0;

        if(!p) {
                if(sock->is_blocked) {






reply via email to

[Prev in Thread] Current Thread [Next in Thread]