Simple Email Issue

Discussion in 'PHP' started by fwof1976, Aug 29, 2013.

  1. #1
    I had this code working at one point, then as I finished the website, it stopped working for me. I am not sure what to do. I have tried using different PHP code and it still wont send the email. It transitions as it should from the HTML page to the PHP page, but doesnt send the email out. Any help would be great.

    PHP PAGE:
    <?php
    $to = "fishwithoutfeet@gmail.com";
    $subject = "Website Message";
    
    $message = "Confidential    " . $_POST['confidential_0'] . "\r\n" . "\r\n" .
    "Prayer Request " . $_POST['info_0'] . "\r\n" .
    "Message for Pastor Tim: " . $_POST['info_1'] . "\r\n" .
    "Message for Pastor Caleb: " . $_POST['info_2'] . "\r\n" .
    "Message for Pastor Andrew: " . $_POST['info_3'] . "\r\n" .
    "Message for Pastor Steven: " . $_POST['info_4'] . "\r\n" .
    "Message for Tonya: " . $_POST['info_5'] . "\r\n" .
    "Other: " . $_POST['info_6'] . "\r\n" .
    "Name: " . $_POST['name'] . "\r\n" .
    "Email: " . $_POST['email'] . "\r\n" .
    "Phone Number: " . $_POST['phone'] . "\r\n" . "\r\n" .
    "Reason for Contact: " . $_POST['content'];
    $from = $_POST['email'];
    $headers = "From: $from" . "\r\n";
    $headers = "Bcc: fishwithoutfeet@yahoo.com" . "/r/n";
    mail($to,$subject,$message,$headers);
    ?>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Bluffton Nazarene Church</title>
    <link href="McConnehey_Final2.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #apDiv1 {
            position:absolute;
            width:200px;
            height:115px;
            z-index:1;
            margin-left: auto;
            left: 33%;
    }
    </style>
    <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    
    
    <div id="wrapper">
    <div id="apDiv1"><img src="images/logo.png" width="491" height="265" alt="Bluffton Nazarene Church Logo" /></div>
    <div id="header">
    </div>
    <div class="sidebar">
      <ul id="MenuBar1" class="MenuBarVertical">
      <li><a href="index2.html">Home</a></li>
        <li><a class="MenuBarItemSubmenu" href="#">Want to Know Jesus?</a>
          <ul>
            <li><a href="recjesus.html">Receiving Jesus</a></li>
            <li><a href="whatnow.html">What Now?</a></li>
            <li><a href="jesusvid.html">Jesus Video</a></li>
          </ul>
        </li>
        <li><a href="aboutus.html">About Us</a></li>
        <li><a class="MenuBarItemSubmenu" href="#">Our Staff</a>
          <ul>
            <li><a href="tmiller.html">Lead Pastor Tim Miller</a>          </li>
            <li><a href="creynolds.html">Pastor of Worship & Visitation Caleb Reynolds</a></li>
            <li><a href="amiller.html">Pastor of Youth and Senior Adults Andrew Miller</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Ministries</a>
          <ul>
            <li><a href="children.html">Children</a></li>
            <li><a href="teens.html">Teens</a></li>
            <li><a href="adults.html">Adults</a></li>
            <li><a href="senioradults.html">Senior Adults</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Resources</a>
          <ul>
            <li><a href="sermons.html">Sermons</a></li>
            <li><a href="booksandsites.html">Books and Websites</a></li>
            <li><a href="assistance.html">Assistance</a></li>
          </ul>
        </li>
        <li><a href="contactus.html">Contact Us</a></li>
      </ul>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class="calendar">
      <script>
      // Other settings you can customize for your site
      var lcPopupColor="rgba(230, 230, 230, .9)"; /* Try other values like: rgb(230,230,230), #b0c4de, yellow, etc */
      var lcPopupOutline="#333333";
      var lcPopupCornerRadius=20; /* Set to 0 for square corners */
    </script>
    <script type="text/javascript" src='http://www.localendar.com/js/PublishedIncludeMini.js'></script>
    
    <!-- Place this line where you would like the calendar to appear (in a <div>, table, etc) -->
    <script type="text/javascript" src='http://www.localendar.com/public/bln1or5?include=Y&style=M5'></script>
    </div>
    <div class="info">
    <p><span class="headlineSM">Office Hours:</span><br />
      Mon - Fri 8:30-4:30  260.824.0460
    </p>
    <p> <span class="headlineSM">Sunday</span><br />
      Sunday School:  9:00-10:00am<br />
      Morning Worship:  10:15-11:30am<br />
      Evening Worship:  6:00-7:00pm
    </p>
    <p>&nbsp;</p>
    <span class="headlineSM">Wednesday</span><br />
    Teens:  6:30-8:00pm<br />
    Children:  7:00-8:00pm<br />
    Adult Bible Study:  7:00-8:00pm<br />
    Dare 2 Care:  7:00-8:00pm
    <p>&nbsp;</p>
    <p class="headlineSM">Español</br>
    <p>La Escuela del domingo: ESL 9:00-10:00am (segunda Lengua inglesa) : El Culto <br />
      de la Mañana 9:00-10:00am</p>
    <p>(Tradujo de inglés a español) : 10:15-11:30am<br /> Culto Nocturno: 6:00-7:00pm</p>
    <p>Los Jóvenes del miércoles: Los Niños 6:30-8:00pm: 7:00-8:00pm</p>
    <p>Estudio <br />
      Adulto de Biblia: 7:00-8:00pm</p>
    <p>e Atreve 2 Cuidado: 7:00-8:00pm</p>
    </p>
    </div>
    </div>
    <div class="content">
    
    <h2>Thanks!</h2>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p class="home"><a href="index2.html">RETURN HOME</a></p>
    </div>
    <div id="clrbox"></div>
    <div id="footer">
    
    <p><strong><a href="index2.html">Home</a></strong>  |  <strong><a href="recjesus.html">Want to Know Jesus?</a></strong>  | <strong><a href="aboutus.html">About Us</a></strong> | <strong><a href="contactus.html">Contact Us</a></strong></p>
    <h3>&copy;Copyright 2012 Bluffton Church of the Nazarene</h3>
    Site Designed By <a href="http://www.fishwithoutfeet.com"><span class="biz">Fish Without Feet Graphic Design</span></a>
    </div></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>
    PHP:
    HTML PAGE:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Bluffton Nazarene Church</title>
    <link href="McConnehey_Final2.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #apDiv1 {
            position:absolute;
            width:960px;
            height:115px;
            z-index:1;
            margin-left: auto;
            margin-right: auto;
    }
    </style>
    <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script><script src="../SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
    <script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
    <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
    <link href="../SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />
    <link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
    <link href="forms.css" rel="stylesheet" type="text/css" />
    <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <div id="wrapper">
    <div id="header">
    <div id="apDiv1"><img src="images/logo.png" width="491" height="265" alt="Bluffton Nazarene Church Logo" /></div>
    </div>
    <div class="sidebar">
      <ul id="MenuBar1" class="MenuBarVertical">
      <li><a href="index2.html">Home</a></li>
        <li><a class="MenuBarItemSubmenu" href="#">Want to Know Jesus?</a>
          <ul>
            <li><a href="recjesus.html">Receiving Jesus</a></li>
            <li><a href="whatnow.html">What Now?</a></li>
            <li><a href="jesusvid.html">Jesus Video</a></li>
          </ul>
        </li>
        <li><a href="aboutus.html">About Us</a></li>
        <li><a class="MenuBarItemSubmenu" href="#">Our Staff</a>
          <ul>
            <li><a href="tmiller.html">Pastor Tim Miller</a></li>
            <li><a href="creynolds.html">Pastor Caleb Reynolds</a></li>
            <li><a href="amiller.html">Pastor Andrew Miller</a></li>
            <li><a href="sspencer.html">Pastor Steven Spencer</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Ministries</a>
          <ul>
            <li><a href="children.html">Children</a></li>
            <li><a href="teens.html">Teens</a></li>
            <li><a href="adults.html">Adults</a></li>
            <li><a href="senioradults.html">Senior Adults</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Resources</a>
          <ul>
            <li><a href="sermons.html">Sermons</a></li>
            <li><a href="booksandsites.html">Books and Websites</a></li>
            <li><a href="assistance.html">Assistance</a></li>
          </ul>
        </li>
        <li><a href="contactus.html">Contact Us</a></li>
      </ul>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class="calendar">
      <script>
      // Other settings you can customize for your site
      var lcPopupColor="rgba(230, 230, 230, .9)"; /* Try other values like: rgb(230,230,230), #b0c4de, yellow, etc */
      var lcPopupOutline="#333333";
      var lcPopupCornerRadius=20; /* Set to 0 for square corners */
    </script>
    <script type="text/javascript" src='http://www.localendar.com/js/PublishedIncludeMini.js'></script>
    
    <!-- Place this line where you would like the calendar to appear (in a <div>, table, etc) -->
    <script type="text/javascript" src='http://www.localendar.com/public/bln1or5?include=Y&style=M5'></script>
    </div>
    <div class="info">
    <p><span class="headlineSM">Office Hours:</span><br />
      Mon - Fri 8:30-4:30  260.824.0460
    </p>
    <p> <span class="headlineSM">Sunday</span><br />
      Sunday School:  9:00-10:00am
      Morning Worship:  10:15-11:30am
      Evening Worship:  6:00-7:00pm
    </p>
    <p>&nbsp;</p>
    <span class="headlineSM">Wednesday</span><br />
    Teens:  6:30-8:00pm
    Children:  7:00-8:00pm
    Adult Bible Study:  7:00-8:00pm
    Dare 2 Care:  7:00-8:00pm
    <p>&nbsp;</p>
    <p class="headlineSM">Español</br>
    <p>La Escuela del domingo: ESL 9:00-10:00am (segunda Lengua inglesa) : El Culto <br />
      de la Mañana 9:00-10:00am</p>
    <p>(Tradujo de inglés a español) : 10:15-11:30am Culto Nocturno: 6:00-7:00pm</p>
    <p>Los Jóvenes del miércoles: Los Niños 6:30-8:00pm: 7:00-8:00pm</p>
    <p>Estudio <br />
      Adulto de Biblia: 7:00-8:00pm</p>
    <p>e Atreve 2 Cuidado: 7:00-8:00pm</p>
    </p>
    </div>
    </div>
    <div class="content">
    <h1>Needing to Contact the Church?</h1>
    <p>Help Us Meet Your Needs, please fill in all fields:</p>
    <form id="contact" name="contact" method="post" action="email_form.php">
      <fieldset>
        <legend>Your Contact Information</legend>
        <p></p>
        <label for="name">Name:</label>
        <input type="text" name="name" id="name" />
        <br />
        <label for="phone">Phone:</label>
        <input type="text" name="phone" id="phone" />
        <br />
        <span id="email">
        <label for="email">Email:</label>
        <input type="text" name="email" id="email" />
        <span class="textfieldRequiredMsg">Required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
      </fieldset>
      <p>&nbsp;</p>
      <fieldset>
        <legend>How May We Serve You?</legend>
        <p>
        <p>Do You Wish This to be Confidential?<br />
        <span id="spryradio1">
          <label>
            <input type="radio" name="confidential_0" value="PRIVATE" id="confidential_0" />
            yes</label>
          <br />
          <label>
            <input type="radio" name="confidential_1" value="Public" id="confidential_1" />
            no</label>
          <br />
          <span class="radioRequiredMsg">Please make a selection.</span></span></p>
          <p>&nbsp;</p>
          <p>
            <label>
              <input type="checkbox" name="info_0" value="prayer" id="info_0" />
              Prayer Request</label>
            <br />
            <label>
              <input type="checkbox" name="info_1" value="AttnTimMiller" id="info_1" />
              Message for Pastor Tim Miller</label>
            <br />
            <label>
              <input type="checkbox" name="info_2" value="AttnCalebReynolds" id="info_2" />
              Message for Pastor Caleb Reynolds</label>
            <br />
            <label>
              <input type="checkbox" name="info_3" value="AttnAndrewMiller" id="info_3" />
              Message for Pastor Andrew Miller</label>
            <br />
            <label>
              <input type="checkbox" name="info_4" value="AttnStevenSpencer" id="info_4" />
              Message for Pastor Steven Spencer</label>
            <br />
            <label>
              <input type="checkbox" name="info_5" value="AttnTonya" id="info_5"  />
              Church Office</label>
            <br />
            <label>
              <input type="checkbox" name="info_6" value="other" id="info_6" />
              Other</label>
            <br />
          </p>
    <br />
          <p>&nbsp;</p>
        <p><span id="sprytextarea1">
          <label for="content">Reason for Contact:</label>
          <br />
          <textarea name="content" id="content" cols="60" rows="10"></textarea>
          <span class="textareaRequiredMsg">Required.</span></span></p>
      </fieldset>
      <p>
        <input type="submit" name="submit" id="submit" value="SEND" />
        <input type="reset" name="reset" id="reset" value="RESET" />
      </p>
    </form>
    <p>&nbsp;</p>
    </div>
    <div id="clrbox"></div>
    <div id="footer">
    
    <p><strong><a href="index2.html">Home</a></strong>  |  <strong><a href="recjesus.html">Want to Know Jesus?</a></strong>  | <strong><a href="aboutus.html">About Us</a></strong> | <strong><a href="contactus.html">Contact Us</a></strong></p>
    <h3>&copy;Copyright 2012 Bluffton Church of the Nazarene</h3>
    Site Designed By <a href="http://www.fishwithoutfeet.com"><span class="biz">Fish Without Feet Graphic Design</span></a>
    </div></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
    var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1", {validateOn:["blur"]});
    var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur"]});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("email", "email", {validateOn:["blur"]});
    </script>
    </body>
    </html>
    HTML:
     
    fwof1976, Aug 29, 2013 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #2
    your code looks ok, are there any error messages? did you move servers?
     
    creativeGenius, Aug 29, 2013 IP
  3. fwof1976

    fwof1976 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    No error messages and the server has been the same from the get go, which is why I am so confused. I suppose I can start the main site again from scratch and see if that fixes it, but trying not to.
     
    fwof1976, Aug 29, 2013 IP
  4. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #4
    try to send a test email eg: mail(','test', 'my message') and see if it goes through
    also make sure you enable error reporting
     
    creativeGenius, Aug 29, 2013 IP
  5. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #5
    Where are you running this script on, localhost or the actual server? I am asking because your localhost may not be configured to send actual mails.

    If you are running this on server, Test the result of the mail function like this:
    
    $mail_res = mail($to,$subject,$message,$headers);
    if(!$mail_res)
         die("Mail not sent");
    else
       die("mail successfully sent");
    
    PHP:
    If the script dies with "mail not sent" message, you can check the server config to see if for some reason mails are not being sent. However if the script dies with "mail successfully sent" message, then it probably going to your spam folder.
     
    samyak, Aug 29, 2013 IP
  6. fwof1976

    fwof1976 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    This is being run on an actual server. It worked at one point and once building the site it stopped working. I tried removing all code besides what was needed for the form and the email and I am still not getting it to send. Well it says it sends, but nothing ever arrives. I am going to try testing it as mentioned above.
     
    fwof1976, Sep 3, 2013 IP
  7. fwof1976

    fwof1976 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    I tried the test and it stated it was successfully sent. So somewhere between being sent and my test email it is getting lost. I have checked my spam and everything, I have even used other email addresses, so I am not sure what is happening to it.


     
    fwof1976, Sep 3, 2013 IP
  8. fwof1976

    fwof1976 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    I used the code on another server and had no issues emailing. It seems the server it was on was either blacklisted or just having issues sending and receiving emails. Thanks for the input!
     
    fwof1976, Sep 3, 2013 IP
  9. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #9
    Getting true on "mail()" statement doesn't mean that the mail has been delivered to the email inbox, it just means that it has been accepted by the server for delivery.
     
    samyak, Sep 4, 2013 IP
  10. topcoder

    topcoder Well-Known Member

    Messages:
    125
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    138
    #10
    Look in your PHP.INI and check the your mail settings

    [mail function]
    SMTP = localhost
    smtp_port = 25
     
    topcoder, Sep 4, 2013 IP