mail scripts won't work

Discussion in 'PHP' started by goltoof, Jun 16, 2010.

  1. #1
    I've been tearing my hair out for 3 days now over something that some 12 year old could probably do in 10 minutes in his sleep.

    My Joomla site sends mail just fine, but I can't even get the simplest php script to send mail. By simplest I mean

    
    <?php
    $txt = "Some text";
    
    mail ("my@email.com","Test subject",$txt);
    ?>
    
    Code (markup):
    I'm using Ubuntu server, sendmail is all configured. Joomla sends just fine, I'm trying to send from a simple form on a webpage outside of Joomla which brings me to believe that there's something I'm not including in the script that it needs to work.

    Can you break down each thing that I should check on the server and each thing I should include in the script to just make it work?
     
    goltoof, Jun 16, 2010 IP
  2. Chronomus

    Chronomus Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Perhaps the reason why it doesn't work is simply because it's too simple. :p The email provider that you're using to receive the mail probably discards your mail because it doesn't contain basic headers such as the 'from' header. I suggest you refer to php.net/mail and look at the examples. You should also look at Joomla's code to see how they do it.
     
    Chronomus, Jun 16, 2010 IP
  3. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #3
    + email "from" must be real for your site
     
    netload, Jun 17, 2010 IP