Problem with PHP email

Discussion in 'Email' started by SToms, Nov 11, 2014.

  1. $host = "mail host address";
    $username = "[email protected]";
    $password = "apassword";

    $headers = array ('From' => $username,
    'To' => $to,
    'Reply-To' => $from,
    'Cc' => $from,
    'Subject' => $subject,
    'Content-type' => "text/html; charset=iso-8859-1");
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($to, $from, $headers, $header.$body.$bottom);
    $mail2 = $smtp->send($from, $headers, $header.$body.$bottom);

    That is the code I am using, I have two problems.
    1) Warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory
    2) Fatal error: Failed opening required 'Mail.php' (include_path='.;C:\Program Files (x86)\PHP\v5.3\pear\pear')

    I can't find a Mail.php file on my server, or in any of my backup files. What do I need in one? Is this code still good to use with the recent updates, or do I need new code?
     
  2. ComputerMan

    ComputerMan Winhost Staff

    Try using our sample code in our knowledge base article here: https://support.Winhost.com/kb/a826/how-to-send-email-from-a-php-application.aspx

    The require_once"Mail.php"; is needed in your code but the file should already be on the server. You don't need to add it to your root directory.

    If you're still having an issue try changing the PHP version from version 5.3 to version 5.4 in the control panel for your site account.

    You can change it under the "Sites" tab https://cp.Winhost.com/sites/

    Click on the domain name.

    On the next page click on "PHP Version" box. Select version 5.4 and click on "Update".

    Then go back to your control panel's "Site Manager" page and recycle your application pool.

    Then try your script again.
     
    Last edited by a moderator: Oct 14, 2015
  3. Since the Mail.php file isn't found, and if I understand you correctly, it should be on the server then it is missing? This code has been used for a few years now without issues until recently. I am wondering if something got changed server wise.
     
  4. ComputerMan

    ComputerMan Winhost Staff

    Can you try changing the version to 5.4.

    If that doesn't work please write in a ticket to our support department and provide them with step by step instructions on how to recreate the issue on their end. Also, provide them with the location of were your code is located on the site account.
     
    Last edited by a moderator: Oct 14, 2015
  5. Will do, thank you.
     

Share This Page