Web Hosting
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Default Cant get PHP mail to work. Driving me nuts

    Hi All,

    I have read all of the articles and all of the kb's and searched for hours, but still cant find a solution to get PHP Mail to send a mail. The function always returns false. Something must be misconfigured somewhere.

    Any ideas? This is the exact code in the PHP file that is run:

    <?php
    $body="<em>HTML</em> formatted <strong>Message</strong";

    $headers = "From: orders@my-siteground-domain.com \r\n";
    $headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
    $headers .= "MIME-Version: 1.0 ";
    if (mail("someaddress@customers-address.com", "An HTML Message", $body, $headers)) {
    echo "It worked";
    } else {
    echo "It failed";
    }
    ?>

    Naturally, I have changed the domain names etc....for privacy.

    Thanks,
    Gtoe.

  2. #2

    Default

    1) You cannot if a mail. Mail does not return a true or false. It just happens. So your if statement is invalid, causing issues.

    2) You did not close your mail tag correctly.

    Just try this:
    [code]
    mail('youremail@domain.com', 'test subject', 'test content');
    [/code]
    and see if it goes through. If it works, it means your server is fine and code is broken. if that doesnt send, open a ticket with SG.

  3. #3
    Join Date
    Jul 2010
    Posts
    2

    Default

    Collin, thanks so much for taking the time to reply.

    Would you believe that it just started working right before I tried your simplified code. For two days -- nothing -- then it worked with no code changes. I am guessing siteground must have spotted something misconfigured somewhere.

    Anyway, all is well now. Thanks again,

    Gtoe.

  4. #4

    Default

    Quote Originally Posted by gtoe View Post
    Collin, thanks so much for taking the time to reply.

    Would you believe that it just started working right before I tried your simplified code. For two days -- nothing -- then it worked with no code changes. I am guessing siteground must have spotted something misconfigured somewhere.

    Anyway, all is well now. Thanks again,

    Gtoe.
    All right! Glad to hear it works again. Best of luck with the website.

  5. #5

    Default

    Just for the history mail function returns boolean values, true on success false on failure.

Similar Threads

  1. SEO does not work
    By Der Vogel in forum Free Joomla Templates
    Replies: 3
    Last Post: 02-10-2010, 10:37 AM
  2. Pspell doesn't work...
    By Floft in forum Hosting Related Questions
    Replies: 1
    Last Post: 08-21-2008, 09:46 AM
  3. Word Wrap driving me potty
    By Magpie13 in forum Free Joomla Templates
    Replies: 3
    Last Post: 05-28-2008, 09:31 AM
  4. E-mail on Junk mail folder
    By junaid in forum Customers' experience and suggestions
    Replies: 1
    Last Post: 05-02-2006, 03:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •