Advertisement
dharris

PHP Mail Script Test

Mar 31st, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1. <?php
  2.  
  3.     /*
  4.     DONT FORGET TO DELETE THIS SCRIPT WHEN FINISHED!
  5.     */
  6.  
  7.     ini_set( 'display_errors', 1 );
  8.     error_reporting( E_ALL );
  9.    
  10.     $from = '[email protected]';
  11.    
  12.     /*
  13.     ini_set( 'SMTP', 'smtp.example.com' );
  14.     ini_set( 'SMTP_PORT', 25 );
  15.     ini_set( 'sendmail_from', $from );
  16.     */
  17.    
  18.     $server = array(
  19.         'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT',
  20.         'SERVER_ADMIN', 'SERVER_SIGNATURE', 'SERVER_SOFTWARE',
  21.         'REMOTE_ADDR', 'DOCUMENT_ROOT', 'REQUEST_URI',
  22.         'SCRIPT_NAME', 'SCRIPT_FILENAME',
  23.     );
  24.    
  25.     $to      = ( isset( $_GET['email'] ) ? $_GET['email'] : FALSE );
  26.     $subject = 'Mail Test Successful for ' . $_SERVER['HTTP_HOST'];
  27.     $message = '';
  28.    
  29.     if ( ! $to )
  30.     {
  31.         echo '<strong>Set $_GET[\'email\'].</strong>';
  32.         exit;
  33.     };
  34.    
  35.     foreach ( $server as $s )
  36.     {
  37.         $message .= sprintf( '%s: %s', $s, $_SERVER[$s] ) . PHP_EOL;
  38.     };
  39.    
  40.     $headers = 'From: ' . $from . PHP_EOL
  41.          . 'Reply-To: ' . $from . PHP_EOL
  42.          . 'X-Mailer: PHP/' . phpversion();
  43.    
  44.     if ( isset( $_GET['send'] ) && $_GET['send'] === 'true' )
  45.     {                  
  46.         $success = mail( $to, $subject, $message, $headers );
  47.     }
  48.     else
  49.     {
  50.         echo '<strong>&quot;<a href="/mail_test.php?email=' . $to . '&send=true">'
  51.          . '/mail_test.php?email=' . $to . '&send=true</a>&quot; to send a test e-mail.</strong>';
  52.     };
  53.    
  54.     if ( isset( $success ) )
  55.     {  
  56.         echo 'E-mail sent to: ' . $to;
  57.         echo '<br />';
  58.         echo 'Successful mail?: <strong ' . ( $success ? 'style="color:green;">YES' : 'style="color:red;">NO' ) . '</strong>';
  59.     }
  60.     else
  61.     {
  62.         echo '<br />';
  63.         echo 'E-mail set as: '.$to;
  64.     };
  65.    
  66.     echo '<hr />'; 
  67.     echo '<style>   * { font-family: Helvetica, Arial, sans-serif;  } th { text-align: left; } td { padding: 3px 5px; } </style>';
  68.     echo '<table>';
  69.    
  70.     foreach ( $server as $s )
  71.     {
  72.         echo '<tr><th>$_SERVER[\'' . $s . '\']</th><td>' . $_SERVER[$s] . '</td></tr>';
  73.     };
  74.    
  75.     echo '</table>';
  76.    
  77.     if ( isset( $success ) )
  78.     {
  79.         echo '<!--';
  80.         var_dump( $success );      
  81.         echo '-->';
  82.     };
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement