Problems with PHP mail not working

Discussion in 'Email' started by Craigsn, May 10, 2015.

  1. I have used the sample "How to send email from a php application", and just put in my hosting email information:
    <html>
    <head><title>Test email via php</title></head>
    <body>
    <?php
    require_once"Mail.php";
    $from = "Sender <postmaster@HostingAccountDomain.com>";
    $to = "Recipient <user@HostingAccountDomain.com>";
    $subject = "This is a test email sent via php";
    $body = "This is a test email";
    $host = "mail.HostingAccountDomain.com";
    $username = "postmaster@HostingAccountDomain.com";
    $password = "email_password";
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    ?>
    </body>
    </html>


    When I run the html file with my info, the web page comes back as:
    "; $to = "Recipient "; $subject = "This is a test email sent via php"; $body = "This is a test email"; $host = "mail.xxxxx.com"; $username = "xxxx@xxxxxxx.com"; $password = "xxxxxxxxxxxx"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); ?> -

    So I don't know where it is failing. I see that the page is looking for mail.php, but I don't see it on my site.

    Thanks for any help you may be able to provide.
    Craig
     
  2. Elshadriel

    Elshadriel Winhost Staff

    Name the file with a .php extension. IIS won't process .html files as PHP code unless you tweak the handler mapping.
     
    Michael likes this.
  3. Hi Elshadriel,
    Ok, I renamed it as a PHP file, removing the html stuff. I tried running it, and nothing happened this time. I then put print statements in to see where it stopped, and it stops on the first line, 'require_once "Mail.php"; It hits the 1st print statement, but not the 2nd one which is immediately after that line.

    Thanks again for your quick response,
    Criag
     
  4. ComputerMan

    ComputerMan Winhost Staff

    Try changing the PHP version within the control panel for the site account.

    Log in the site account.

    Click on the "Sites" tab at the top.

    Click on the site account.

    Next click on PHP version box and change the PHP version to something else.

    Then recycle your application pool. Try to see if the email message is sent after you change the version.
     
    Michael likes this.
  5. I changed it from PHP 5.5 to 5.4, recycled the app pool, waited a few minutes and I get the same results.
     
  6. ComputerMan

    ComputerMan Winhost Staff

    Open a support ticket with us and provide us with the link to this forum post (this will help us understand your issue). We will need to test out your PHP version for your site account to make sure email messages can be sent out.
     
    Last edited by a moderator: Oct 14, 2015
  7. It's done. Thanaks
     
  8. Ok Winhost staff, I have a problem now. I need to have PHP 5.5 for an application I am running. But your mail application does not work with PHP 5.5, or 5.4, only version 5.3. So do you have another PHP mail script that works with 5.5?

    Thanks
     
    Last edited by a moderator: Oct 14, 2015
  9. Seeing if this thread is alive or not!
     
  10. ComputerMan

    ComputerMan Winhost Staff

    We sent the following email messages to all of our customers regarding an update we are doing to the PHP versions on the server. Below is the email message.
    So after we do the update on May 27, 2015 and you still can't send out email. Open a ticket and let us know. You can refer to this forum post too.
     
    Last edited by a moderator: Oct 14, 2015
    Elshadriel and Michael like this.

Share This Page