    XPM2 SMTP & POP3 Examples

    Notice: XPM2 package contain a folder "EXAMPLES" with SMTP & POP3 simple and complex examples.

    SMTP Example:

    // path to smtp.php from XPM2 package
    require_once '/path/smtp.php';

    $mail = new SMTP;
    $mail->From('me@domain.com');
    $mail->AddTo('client@destination.com');
    $mail->Text('It is simple to use XPM2');
    $sent = $mail->Send('Hello World!');

    echo $sent ? 'Success' : 'Error';

    POP3 Example:

    // path to pop3.php from XPM2 package
    require_once '/path/pop3.php';

    if($conn = POP3::Connect('mail.domain.com', 'username', 'password')){
    	$stat = POP3::pStat($conn);
    	if($stat[0] > 0){
    		// get last mail
    		$data = POP3::pRetr($conn, $stat[0]);
    		POP3::pQuit($conn);
    		echo $data ? $data : 'Error.';
    	}else echo 'Mail is empty!';
    }else echo 'Can not connect!';

    [ Comments ]

    Last update: Wednesday, June 28, 2006