Skip to content

Instantly share code, notes, and snippets.

@Dreyer
Created June 20, 2012 09:06
Show Gist options
  • Select an option

  • Save Dreyer/2958946 to your computer and use it in GitHub Desktop.

Select an option

Save Dreyer/2958946 to your computer and use it in GitHub Desktop.

Revisions

  1. Matthew Dreyer revised this gist Jun 20, 2012. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions mail-test.php
    Original file line number Diff line number Diff line change
    @@ -16,9 +16,10 @@
    */

    $server = array(
    'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT', 'SERVER_ADMIN',
    'SERVER_SIGNATURE', 'SERVER_SOFTWARE', 'REMOTE_ADDR', 'DOCUMENT_ROOT',
    'REQUEST_URI', 'SCRIPT_NAME', 'SCRIPT_FILENAME',
    'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT',
    'SERVER_ADMIN', 'SERVER_SIGNATURE', 'SERVER_SOFTWARE',
    'REMOTE_ADDR', 'DOCUMENT_ROOT', 'REQUEST_URI',
    'SCRIPT_NAME', 'SCRIPT_FILENAME',
    );

    $to = ( isset( $_GET['email'] ) ? $_GET['email'] : FALSE );
    @@ -37,8 +38,8 @@
    };

    $headers = 'From: ' . $from . PHP_EOL
    . 'Reply-To: ' . $from . PHP_EOL
    . 'X-Mailer: PHP/' . phpversion();
    . 'Reply-To: ' . $from . PHP_EOL
    . 'X-Mailer: PHP/' . phpversion();

    if ( isset( $_GET['send'] ) && $_GET['send'] === 'true' )
    {
  2. Matthew Dreyer revised this gist Jun 20, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions mail-test.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    <?php

    /*
    DONT FORGET TO DELETE THIS SCRIPT WHEN FINISHED!
    */

    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );

  3. Matthew Dreyer created this gist Jun 20, 2012.
    78 changes: 78 additions & 0 deletions mail-test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    <?php

    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );

    $from = 'webmaster@example.com';

    /*
    ini_set( 'SMTP', 'smtp.example.com' );
    ini_set( 'SMTP_PORT', 25 );
    ini_set( 'sendmail_from', $from );
    */

    $server = array(
    'HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR', 'SERVER_PORT', 'SERVER_ADMIN',
    'SERVER_SIGNATURE', 'SERVER_SOFTWARE', 'REMOTE_ADDR', 'DOCUMENT_ROOT',
    'REQUEST_URI', 'SCRIPT_NAME', 'SCRIPT_FILENAME',
    );

    $to = ( isset( $_GET['email'] ) ? $_GET['email'] : FALSE );
    $subject = 'Mail Test Successful for ' . $_SERVER['HTTP_HOST'];
    $message = '';

    if ( ! $to )
    {
    echo '<strong>Set $_GET[\'email\'].</strong>';
    exit;
    };

    foreach ( $server as $s )
    {
    $message .= sprintf( '%s: %s', $s, $_SERVER[$s] ) . PHP_EOL;
    };

    $headers = 'From: ' . $from . PHP_EOL
    . 'Reply-To: ' . $from . PHP_EOL
    . 'X-Mailer: PHP/' . phpversion();

    if ( isset( $_GET['send'] ) && $_GET['send'] === 'true' )
    {
    $success = mail( $to, $subject, $message, $headers );
    }
    else
    {
    echo '<strong>Set &quot;<a href="./?email=' . $to . '&send=true">'
    . './?email=' . $to . '&send=true</a>&quot; to send a test e-mail.</strong>';
    };

    if ( isset( $success ) )
    {
    echo 'E-mail sent to: ' . $to;
    echo '<br />';
    echo 'Successful mail?: <strong ' . ( $success ? 'style="color:green;">YES' : 'style="color:red;">NO' ) . '</strong>';
    }
    else
    {
    echo '<br />';
    echo 'E-mail set as: '.$to;
    };

    echo '<hr />';
    echo '<style> * { font-family: Helvetica, Arial, sans-serif; } th { text-align: left; } td { padding: 3px 5px; } </style>';
    echo '<table>';

    foreach ( $server as $s )
    {
    echo '<tr><th>$_SERVER[\'' . $s . '\']</th><td>' . $_SERVER[$s] . '</td></tr>';
    };

    echo '</table>';

    if ( isset( $success ) )
    {
    echo '<!--';
    var_dump( $success );
    echo '-->';
    };
    ?>