WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP3 PHP POP3 SMTP MAIL
Categories : PHP, Email, HTML and PHP Update Picture
Unk Unk
Date : Feb 22nd 1999
Grade : 3 of 5 (graded 12 times)
Viewed : 45368
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Unk Unk
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
/* Pop3 Functions.
Smtp Functions. [Added later, going to split]

For a real example take a look at:
http://www.triple-it.nl/pop3/

I have just started to explore the world of PHP3,
so excuse (and correct me :) if I'm doing something wrong.

Unk. (rgroesb@triple-it.nl)
*/

function pop3_open($server, $port)
{
        global $POP3_GLOBAL_STATUS;

        $pop3 = fsockopen($server, $port);
        if ($pop3 <= 0) return 0;

        $line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

        if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

        return $pop3;
}

function pop3_user($pop3, $user)
{
        global $POP3_GLOBAL_STATUS;

        fputs($pop3, "USER $user\r\n");
        $line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);
        
        if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

        return 1;
}

function pop3_pass($pop3, $pass)
{
        global $POP3_GLOBAL_STATUS;

        fputs($pop3, "PASS $pass\r\n");
        $line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);
        
        if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

        return 1;
}

function pop3_stat($pop3)
{
        global $POP3_GLOBAL_STATUS;

        fputs($pop3, "STAT\r\n");
        $line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

        if (!eregi("+OK (.*) (.*)", $line, $regs))
                return 0;

        return $regs[1];
}

function pop3_list($pop3)
{        
global $POP3_GLOBAL_STATUS;

fputs($pop3, "LIST\r\n");
$line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

        $i = 0;
        while (substr($line = fgets($pop3, 1024), 0, 1) <> ".")
        {
                $articles[$i] = $line;
                $i++;
        }
        $articles["count"] = $i;

        return $articles;
}

function pop3_retr($pop3, $nr)
{
global $POP3_GLOBAL_STATUS;

fputs($pop3, "RETR $nr\r\n");
$line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

while (substr($line = fgets($pop3, 1024), 0, 1) <> ".")
{
$data[$i] = $line;
$i++;
}
$data["count"] = $i;

return $data;
}

function pop3_dele($pop3, $nr)
{
global $POP3_GLOBAL_STATUS;

fputs($pop3, "DELE $nr\r\n");
$line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;


return 1;
}

function pop3_quit($pop3)
{
global $POP3_GLOBAL_STATUS;

fputs($pop3, "QUIT\r\n");
$line = fgets($pop3, 1024);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] = substr($line, 0, 1);
$POP3_GLOBAL_STATUS[$pop3]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($POP3_GLOBAL_STATUS[$pop3]["LASTRESULT"] <> "+") return 0;

return 1;
}

function smtp_open($server, $port)
{
global $SMTP_GLOBAL_STATUS;

$smtp = fsockopen($server, $port);
if ($smtp < 0) return 0;

$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

return $smtp;
}


function smtp_helo($smtp)
{
global $SMTP_GLOBAL_STATUS;

        /* 'localhost' always works [Unk] */
fputs($smtp, "helo localhost\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

return 1;
}

function smtp_ehlo($smtp)
{
global $SMTP_GLOBAL_STATUS;

        /* Well, let's use "helo" for now.. Until we need the
         extra func's [Unk]
         */
fputs($smtp, "helo localhost\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

return 1;
}


function smtp_mail_from($smtp, $from)
{
global $SMTP_GLOBAL_STATUS;

fputs($smtp, "MAIL FROM: <$from>\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

return 1;
}

function smtp_rcpt_to($smtp, $to)
{
global $SMTP_GLOBAL_STATUS;

fputs($smtp, "RCPT TO: <$to>\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

return 1;
}

function smtp_data($smtp, $subject, $data)
{
global $SMTP_GLOBAL_STATUS;

fputs($smtp, "DATA\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "3") return 0;

        fputs($smtp, "Mime-Version: 1.0\r\n");
        fputs($smtp, "Subject: $subject\r\n");        
        fputs($smtp, "$data\r\n\r\n");
        fputs($smtp, ".\r\n");
$line = fgets($smtp, 1024);
        if (substr($line, 0, 1) <> "2")
                return 0;

return 1;
}

function smtp_quit($smtp)
{
global $SMTP_GLOBAL_STATUS;

fputs($smtp, "QUIT\r\n");
$line = fgets($smtp, 1024);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] = substr($line, 0, 1);
$SMTP_GLOBAL_STATUS[$smtp]["LASTRESULTTXT"] = substr($line, 0, 1024);

if ($SMTP_GLOBAL_STATUS[$smtp]["LASTRESULT"] <> "2") return 0;

        return 1;
}



/*
$pop3 = pop3_open("localhost", "110");
if (!$pop3) {
        printf("[ERROR] Failed to connect to localhost<BR>\n");
        return 0;
}

if (!pop3_user($pop3, "unk")) {
        printf("[ERROR] Username failed!<BR>\n");
        return 0;
}

if (!pop3_pass($pop3, "secret")) {
        printf("[ERROR] PASS failed!<BR>\n");
        return 0;
}

$articles = pop3_list($pop3);
if (!$articles) {
        printf("[ERROR] LIST failed!<BR>\n");
        return 0;
}

for ($i = 1; $i < $articles ["count"] + 1; $i++)
{
        printf("i=$i<BR>\n");
        $data = pop3_retr($pop3,$i);
        if (!$data) {
                printf("data goes wrong on '$i'<BR>\n");
                return 0;
        }
        
        for ($j = 0; $j < $data["count"]; $j++)
        {
                printf("$data[$j]<BR>\n");
        }
}
*/


?>



PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
PHP MultiList Mailing List Manager
Categories : Email, HTML and PHP, PHP
phpEasyMail: An easy way to send data from HTML-forms via EMail.
Categories : Email, HTML and PHP, Complete Programs, PHP
X-Mailer, this php3 script verifies recipient address in three different ways before it sends email. All in one document. Report satus when mail sent.
Categories : PHP, Email, HTML and PHP
Text Wrapping
Categories : PHP, HTML and PHP, Strings
Dynamic CSS generation for multiple website colouring schemes.
Categories : PHP, CSS, HTML and PHP
Solution to those 'tell-a-friend' type email issues
Categories : PHP, Email, Databases, MySQL
Using PHP im HTML image tags
Categories : PHP, HTML and PHP, Graphics, Beginner Guides
A simple php file uploader
Categories : PHP, Filesystem, HTML and PHP
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
email validator check checker email e-mail email address
Categories : PHP, Email, Regexps
Simple class to build tables with style sheets
Categories : HTML and PHP, PHP Classes, PHP
EAvalidator - This class can be used to validate an e-mail address by checking its domain.
Categories : PHP, PHP Classes, Email, Regexps
A class for sending email; it has support for To:, Cc:, Bcc: and Reply-To: headers. It requires that you have sendmail installed.
Categories : Email, PHP Classes, PHP
PHP MIME Decoder. This class decodes Mime Encoded email message. Attachments are stored in a director. Works with Multipart/alternative, multipart/mixed etc. see http://p3mail.com for example.
Categories : PHP, PHP Classes, Email
 Prachya Pantuyakorn wrote : 599
Hi, I`ve tested ur script. It`s very useful. Would u pls give me and idea to create mailbox by using php cript? 

Best regard,
Prachya
 
 Van Lai wrote :1763
i tested the code. work great for the first 17 message. said 'data go wrong on '18' and on. i thought there might something funny with message 18 and greater, so i commented out the for loop that get message and tell it to download 18, 19 one by one successfully.  do you have any idea why?