mail() not sending email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sworden
    New Member
    • Dec 2011
    • 2

    mail() not sending email

    I found the following code and I successfully get the "Your message was sent" message, but no email was actually sent. I checked the spam filter. I work in Notepad++ and I noticed that the word "mail" is not being seen as a function (function words show up blue), but as text (black lettering). Any suggestions?
    Code:
    <?php
    if ($_POST["email"]<>'') {
        $ToEmail = 'itsupport@povpc.org';
        $EmailSubject = 'CPM Database Updates Form';
        $mailheader = "From: ".$_POST["email"]."rn";
        $mailheader .= "Reply-To: ".$_POST["email"]."rn";
        $mailheader .= "Content-type: text/html; charset=iso-8859-1rn";
        $MESSAGE_BODY = "Name: ".$_POST["name"]."";
        $MESSAGE_BODY .= "Email: ".$_POST["email"]."";
        $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."";
        mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
    ?>
    Your message was sent
    <?php
    } else {
    ?>
    <form action="email.php" method="post">
    <table width="400" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td colspan="2"><p>Please fill in the form below and your records will be updated as soon as possible.</p></td>
    </tr>
    <tr>
    <td width="29%" class="bodytext">Your name:</td>
    <td width="71%"><input name="name" type="text" id="name" size="32"></td>
    </tr>
    <tr>
    <td class="bodytext">Email address:</td>
    <td><input name="email" type="text" id="email" size="32"></td>
    </tr>
    <tr>
    <td class="bodytext">Comment:</td>
    <td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
    </tr>
    <tr>
    <td class="bodytext"> </td>
    <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
    </tr>
    </table>
    </form>
    <?php
    };
    ?>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I work in Notepad++ and I noticed that the word "mail" is not being seen as a function (function words show up blue), but as text (black lettering).
    that's irrelevant to PHP. if a function does not exist, it will complain.

    as is commonly known, a successful call to mail() does not guarantee the mail to be sent, only to be delivered to your mail sending binary (usually an instance of sendmail). if sending the mail is successful or not is out of the scope of mail().

    if you want reliable sending of mails, use a mailing library (e.g. SwiftMailer)

    Comment

    Working...