PHP Mail Function Not Working?

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by iharmi53, Dec 5, 2013.

  1. iharmi53

    iharmi53 New Member

    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hello guys,

    I have created this PHP script:

    PHP:
    $to $_POST["email"];
    $subject "FW-Bestilling.DK - Dit brugernavn";

    $message "<html>
    <head>
        <title>FW-Bestilling.DK - Dit brugernavn</title>
    </head>
    <body>

    <p><b>Dit brugernavn er:</b> "
    .$row["user_username"]."</p>

    </body>
    </html>"
    ;
    $message wordwrap($message70"\r\n");

    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: test <noreply@test.dk>\r\n";

    mail($to$subject$message$headers);
    But I don't receive any e-mails to my e-mail (and I do have writen my proper email address into $to), have I done something wrong? Or is the mail function disabled for free x10hosting users? Please help me out.
     
  2. rooxx102

    rooxx102 New Member

    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Change;
    PHP:
    $message wordwrap($message70"\r\n");
    to;
    PHP:
    $message2 wordwrap($message70"\r\n");
    and add '$message2' to your mail(); query.
     
  3. caftpx10

    caftpx10 Well-Known Member

    Messages:
    1,486
    Likes Received:
    106
    Trophy Points:
    63
    Do what roxx102 said, you were basically overwriting a variable.
    You need both so using different names would be the best option.
     
  4. essellar

    essellar Community Advocate Community Support

    Messages:
    3,295
    Likes Received:
    227
    Trophy Points:
    63
    The $x = do_something_to($x); syntax is perfectly fine and will only very rarely cause problems in very specific circumstances, which should be regarded as environmental bugs. (Under the hood, a new string is created with a temporary "name", and its address (pointer, if you will) is assigned to the named variable, abandoning both the old string and the temporary variable. Strings are immutable in most languages; "changing" them means creating a new one and destroying the old one. At no time does $message contain both values, nor is there any point at which there would be any ambiguity.)

    The problem here is that HTML mail won't make it out of the system (phishing and other tricksies are too easy to do with blind links, webbugs and so forth, and getting one of the Free Hosting servers placed on a spam blacklist knocks out everybody's mail and takes a lot of effort to fix). Your email needs to have a plain text part at least, and may need to be just plain text (depending on how the outgoing spam filter is set up at the time).

    If you need fancy formatting for newsletters or marketing pieces, take a look at outboard services like MailChimp/Mandrill (which often have reasonable free level services).
     
  5. mconslau

    mconslau New Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Yeah I use the $x = do_something_to($x) syntax all the time :)
     

Share This Page