By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

mail() not sending email

P: 2
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?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if ($_POST["email"]<>'') {
  3.     $ToEmail = 'itsupport@povpc.org';
  4.     $EmailSubject = 'CPM Database Updates Form';
  5.     $mailheader = "From: ".$_POST["email"]."rn";
  6.     $mailheader .= "Reply-To: ".$_POST["email"]."rn";
  7.     $mailheader .= "Content-type: text/html; charset=iso-8859-1rn";
  8.     $MESSAGE_BODY = "Name: ".$_POST["name"]."";
  9.     $MESSAGE_BODY .= "Email: ".$_POST["email"]."";
  10.     $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."";
  11.     mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
  12. ?>
  13. Your message was sent
  14. <?php
  15. } else {
  16. ?>
  17. <form action="email.php" method="post">
  18. <table width="400" border="0" cellspacing="2" cellpadding="0">
  19. <tr>
  20. <td colspan="2"><p>Please fill in the form below and your records will be updated as soon as possible.</p></td>
  21. </tr>
  22. <tr>
  23. <td width="29%" class="bodytext">Your name:</td>
  24. <td width="71%"><input name="name" type="text" id="name" size="32"></td>
  25. </tr>
  26. <tr>
  27. <td class="bodytext">Email address:</td>
  28. <td><input name="email" type="text" id="email" size="32"></td>
  29. </tr>
  30. <tr>
  31. <td class="bodytext">Comment:</td>
  32. <td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
  33. </tr>
  34. <tr>
  35. <td class="bodytext"> </td>
  36. <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
  37. </tr>
  38. </table>
  39. </form>
  40. <?php
  41. };
  42. ?>
  43.  
Mar 22 '12 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
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)
Mar 22 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.