Sending mail in PHP problem

Discussion in 'HTML / PHP / JavaScript / CSS' started by euphegram, Nov 6, 2022.

  1. I tested the PHP code in the knowledgebase to send email to myself, and installed PEAR, it runs w/o errors (final echo stmt. is displayed) but I don't receive any emails. I also tried it w/o using any $port variable, leaving the default unchanged, didn't help. If anyone can help me out, I'd appreciate it. Thanks. Here is the code I'm using:

    <?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    require_once "Mail.php";
    $from = "[email protected]";
    $to = "[email protected]";
    $subject = "Mail.php test email (post reg. forum)";
    $body = "Test email sent using Mail.php.";
    $port = "587";
    $host = "sm06.internetmailserver.net";
    $username = "[email protected]";
    $password = "xx not shown xx";
    $headers = array ('Date' => date('r'),
    'From' => $from,
    'To' => $to,
    'Subject' => $subject,
    'Message-ID' => '<' . time() . md5($from . $to) . '@treenimation.net>');
    $smtp = Mail::factory('smtp',
    array ('localhost' => $host,
    'host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    echo "Mail.php test"
    ?>
     
  2. martino

    martino DiscountASP.NET Staff

    Open a support ticket so we can check the mail logs for you. If you're not getting any error messages when you are sending, and you aren't receiving any email messages too. We can check to see if our mail server sent them out.
     
  3. I made a newbie mistake, I neglected to make the password of [email protected] match the one in my PHP code. Thanks, Martino.
     

Share This Page