Net_LMTP
[ class tree: Net_LMTP ] [ index: Net_LMTP ] [ all elements ]

Source for file test_lmtp.php

Documentation is available at test_lmtp.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Chuck Hagenbuch <chuck@horde.org>                           |
  17. // |          Jon Parise <jon@php.net>                                    |
  18. // |          Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>      |
  19. // +----------------------------------------------------------------------+
  20.  
  21.  
  22. require_once('Net/LMTP.php');
  23.  
  24.  
  25.  
  26. // The LMTP server
  27. $host="localhost";
  28. // The default LMTP port
  29. $port="2003";
  30. // The username to authenticate to the LMTP server
  31. $user="cyrus";
  32. // The password to authenticate to the LMTP server
  33. $pwd="password";
  34.  
  35.  
  36. //you can create a file called passwords.php and store your $user,$pass,$host and $port values in it
  37. // or you can modify this script
  38. @require_once("./passwords.php");
  39.  
  40.  
  41.  
  42. // The name we send to initiate the LMTP dialog
  43. $localhost="localhost";
  44.  
  45. // The email as we send the email in the LMTP dialog
  46. $from="damian@cnba.uba.ar";
  47. // The email to send the email in the LMTP dialog
  48. //$to="damian@fernandezsosa.com.ar";
  49. $to="damian@1aaafernandezsosa.com.ar";
  50. //$to="damian";
  51.  
  52. // The email text (RFC822 format)
  53. $email="From:damian@cnba.uba.ar\r\nTo:damian@cnba.uba.ar\r\nDate: Wed, 12 Feb 2004 21:07:35 -300\r\nSubject: testing LMTP\r\n\r\nthis is a test email\r\n";
  54.  
  55.  
  56.  
  57. // We create the Net_LMTP instance
  58. $lmtp_conn= new Net_LMTP$host ,  $port $localhost);
  59.  
  60. $lmtp_conn->setDebug(true);
  61. // Connect to the LMTP server
  62. if (PEAR::isError$error $lmtp_conn->connect())) {
  63.     echo "ERROR:" $error->getMessage("\n";
  64.     exit();
  65. }
  66. // Authenticates against the LMTP server using PLAIN method.
  67. if (PEAR::isError$error $lmtp_conn->auth($user,$pwd,'PLAIN'))) {
  68.     echo "ERROR:" $error->getMessage("\n";
  69.     exit();
  70. }
  71. // Send the MAIL FROM: LMTP command
  72. if (PEAR::isError$error $lmtp_conn->mailFrom($from))) {
  73.     echo "ERROR:" $error->getMessage("\n";
  74.     exit();
  75. }
  76.  
  77. // Send the RCPT TO: LMTP command
  78. if (PEAR::isError$error $lmtp_conn->rcptTo($to))) {
  79.     echo "ERROR:" $error->getMessage("\n";
  80.     exit();
  81. }
  82.  
  83. // Send the DATA: LMTP command (we send the email RFC822 encoded)
  84. if (PEAR::isError$error $lmtp_conn->data($email))) {
  85.     echo "ERROR:" $error->getMessage("\n";
  86.     exit();
  87. }
  88. // now the email was accepted by the LMTP server, so we close
  89. // the connection
  90.  
  91.  
  92. // Send the QUIT LMTP command and disconnect from the LMTP server
  93. if (PEAR::isError$error $lmtp_conn->disconnect())) {
  94.     echo "ERROR:" $error->getMessage("\n";
  95.     exit();
  96. }
  97.  
  98.  
  99. ?>

Documentation generated on Mon, 11 Mar 2019 15:45:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.