SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 51
  1. #26
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You are uploading your new script to the server/host right? As you should be seeing one of the die statements or a message at the top of your page stating it is attempting to send the email.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  2. #27
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes I'm changing the script then uploading it to the host, refresh the website enter the details but still receive the same result

    contact.JPG&

  3. #28
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, change the following statement
    PHP Code:
    if ($_POST && $_POST["name"] && preg_match("/^[a-zA-Z0-9 ]+$/i"$_POST["name"]) && $_POST["email"] && preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"$_POST["email"])) { 
    To
    PHP Code:
    if ($_POST && $_POST["name"] && preg_match("/^[a-zA-Z0-9 ]+$/i"$_POST["name"]) !== false && $_POST["email"] && preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"$_POST["email"]) !== false) { 
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  4. #29
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Right now were getting somewhere, - I get the message Attempting to send e-mail...Failed! at the top of the page

  5. #30
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    okay, start off by downloading phpMailer (I'm not sure you'll need this if you host installed phpMailer properly, but you may if they didn't).
    http://sourceforge.net/projects/phpmailer/

    Update your mail logic
    PHP Code:
        include_once('class.phpmailer.php');
        
    $mail = new PHPMailer();
        
    $mail->IsSMTP();
        
    $mail->Host ""// place your smtp host here
        
    $mail->SMTPAuth true;
        
    $mail->Username "" // place your smtp username here
        
    $mail->Password "" // place your smtp password here

        
    $mail->From $_POST["email"];
        
    $mail->FromName $_POST["name"];
        
    $mail->AddAddress("enquiries@.co.uk");

        
    $mail->Subject "Enquiry from the  Website";

        
    // build the email
        
    $s "The following contact form has been submitted:\n\n";

        
    $s .= "=== Customer Details =====\n";
        
    $s .= "Name: " .$_POST["name"]. "\n";
        
    $s .= "Company: " .$_POST["company"]. "\n";
        
    $s .= "Telephone: " .$_POST["telephone"]. "\n";
        
    $s .= "Email Address: " .$_POST["email"]. "\n\n";

        
    $s .= "=== Enquiry Information =====\n";
        
    $s .= trim($_POST["comments"])."\n\n";

        
    $s.= "Generated: " .date("Y-m-d H:i:s");

        
    $mail->Body $s;
        
    $mail->WordWrap 72;

        echo 
    "Attempting to send e-mail...";
        if (
    $mail->Send()) {
            
    $SENT true;
            echo 
    "Success!";
        } else {
            
    $SENT false;
            echo 
    "Failed!";
        } 
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  6. #31
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, dont think I need the mailer as its on the host but what do I do with that code, - add it to the existing script or a new one? & if add to existing, where abouts does it go & do I have to remove anything?

  7. #32
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    $SENT 
    false;
    if (
    $_POST && $_POST["name"] && preg_match("/^[a-zA-Z0-9 ]+$/i"$_POST["name"]) !== false && $_POST["email"] && preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"$_POST["email"]) !== false) {

        include_once(
    'class.phpmailer.php');
        
    $mail = new PHPMailer();
        
    $mail->IsSMTP();
        
    $mail->Host ""// place your smtp host here
        
    $mail->SMTPAuth true;
        
    $mail->Username "" // place your smtp username here
        
    $mail->Password "" // place your smtp password here

        
    $mail->From $_POST["email"];
        
    $mail->FromName $_POST["name"];
        
    $mail->AddAddress("enquiries@.co.uk");

        
    $mail->Subject "Enquiry from the  Website";

        
    // build the email
        
    $s "The following contact form has been submitted:\n\n";

        
    $s .= "=== Customer Details =====\n";
        
    $s .= "Name: " .$_POST["name"]. "\n";
        
    $s .= "Company: " .$_POST["company"]. "\n";
        
    $s .= "Telephone: " .$_POST["telephone"]. "\n";
        
    $s .= "Email Address: " .$_POST["email"]. "\n\n";

        
    $s .= "=== Enquiry Information =====\n";
        
    $s .= trim($_POST["comments"])."\n\n";

        
    $s.= "Generated: " .date("Y-m-d H:i:s");

        
    $mail->Body $s;
        
    $mail->WordWrap 72;

    //    echo "Attempting to send e-mail...";
        
    if ($mail->Send()) {
            
    $SENT true;
    //        echo "Success!";
        
    } else {
            
    $SENT false;
    //        echo "Failed!";
        

    }

    ?>

    <!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" lang="en">

    <head>
        <title></title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta http-equiv="imagetoolbar" content="no" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <meta name="revisit-after" content="7 days">
        <meta name="Copyright" content="Beverley Morris">
        <meta name="Robots" content="all">
        <meta name="language" content="en">
        <meta name="distribution" content="Global">

        <link rel="shortcut icon" href="/favicon.ico" />
        <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />

        <style type="text/css" media="screen">
        <!--
        @import url(css/styles.css);
        -->
        </style>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script> 
        <script src="js/jquery-1.5.1.min.js" type="text/javascript"></script>
         <script src="js/global.js" type="text/javascript"></script>
        <script src="js/jquery.goomaps.js" type="text/javascript"></script>
        
        
        
        
    </head>

    <body>

    <div id="container_header">
        <div id="header">

        <div id="logo"><h1><a href="/" title="Home"><span></span></a></h1></div>

        <div id="header-right">
        <div id="contact">
        Tel: 020   Fax: 020 <br />
        Email: <a href="mailto:enquiries@.co.uk">enquiries@.co.uk</a>
        </div>
        </div>

        <div id="navigation">
            <ul class="navInner">
                <li><a href="/">Homepage</a></li>
                <li><a href="about-us.htm" >About Us</a></li>
                <li>
                    <a href="our-services.htm">Our Services</a>
                    <ul>
                        
                    </ul>
                </li>
                <li>
                    <a href="team-profiles.htm" >Team Profiles</a>
                    <ul>
                        
                    </ul>
                </li>

            <li><a href="contact.php" class="active">Contact Us</a></li>
            </ul>
        </div>

        </div>
    </div>
        
    <div id="container_body">
        <div id="body">
            
            <div class="clearboth">&nbsp;</div>


            <div id="home_panel">

                <div id="home_bottompanel_content">

                <h2>Contact Us</h2>
            
                <div class="goomapsWrapper">
                    <h3>Office</h3>
                    <p>
                        <br />
                        <br />
                        <span>T:</span> +44 020 <br />
                        <span>F:</span> +44 020 <br />
                        <span>DX:</span> <br />
                        <span>E:</span> <a href="mailto:enquiries@.co.uk">enquiries@.co.uk</a>
                        
                    </p>    
                    <div id="map_canvas" class="map_canvas"></div>    
                </div>
                <div class="goomapsWrapper">
                    <h3>Office</h3>
                    <p>

                        <br />
                        <br />
                        <span>E:</span> <a href="mailto:.co.uk">.co.uk</a>
                    </p>                    
                    <div id="map_canvas2" class="map_canvas"></div>                    
                </div>            

                <div>
                <?php if (!$SENT) { ?>

                <?php if (!$SENT && $_POST) { 
                    echo 
    '<p class="red">There was a problem with sending the form.<br />Please check to ensure you have filled in all the fields.</p>';
                } 
    ?>
                <p><b>Enquiry Form</b><br />
                <span class="red">**</span> Indicates required fields</p>
                
                <form name="contact" action="contact.php" method="post">
                <fieldset class="conform">
                <legend>Your Details</legend><br />
                <label for="name">Name</label>
                <input id="name" type="text" size="40" value="<?php echo (isset($_POST["name"])) ? $_POST["name"] : '' ?>" name="name" /> <span class="red">**</span><br />
                <label for="company">Company</label>
                <input id="company" type="text" size="40" value="<?php  echo (isset($_POST["company"])) ? $_POST["company"] : '' ?>" name="company" /><br />
                <label for="telephone">Telephone</label>
                <input id="telephone" type="text" size="40" value="<?php echo  (isset($_POST["telephone"])) ? $_POST["telephone"] : ''?>" name="telephone" /><br />
                <label for="email">Email Address</label>
                <input id="email" type="text" size="40" value="<?php echo (isset($_POST["email"])) ? $_POST["email"] : ''?>" name="email" /> <span class="red">**</span><br />
                </fieldset>

                <fieldset class="conform2">
                <legend>Further Information</legend><br />
                <textarea id="comments" name="comments" size="40" rows="8" cols="50"><?php  echo(isset($_POST["comments"])) ? $_POST["comments"] : '' ?></textarea>
                </fieldset>

                <br />
                <a href="javascript:document.contact.submit();"><img title="" height="43" alt="" src="images/submit.gif" width="102" border="0" /></a>
                </form>
                </div>

                <?php
                    
    } else {
                
    ?>
                <p>Thank you for your enquiry. We will reply as soon as possible.</p>
                <?php
                    
    }
                
    ?>

            </p>

                </div>
            </div>
            
            <div id="ftr">
            <span id="copyright">Copyright &copy; <br />
            Tel: 020 8852 4433 &nbsp;  Fax: 020 8463 9494 &nbsp; Email: <a href="mailto:enquiries@b.co.uk">enquiries@.co.uk</a></span>
            <span id="ftr_links"><a href="terms.htm">Terms of Use</a> <a href="privacy.htm">Privacy Policy</a> <a href="http://www..co.uk" title="Cambridge Web Design and Development by" target="_blank" class="last">Web Design by </a></span>
            <div class="clearboth">&nbsp;</div>
            </div>
            
        </div>

         <script>
             $(document).ready(function(){
             $('#map_canvas').goomaps("init", { 
                center: [51.467434,0.008308],
                zoom: 16,
                    clickable: true,
                    draggable: true,
                    scrollwheel: false,
                OverviewMapControlOptions: false,
             }).goomaps("addmarkers", [{ options: {
                    position: [51.467434,0.008308]

                    
                    
             }}]);
             $('#map_canvas2').goomaps("init", { 
                center: [51.462998,-0.010772],
                zoom: 16,
                    clickable: true,
                    draggable: true,
                    scrollwheel: false,
                OverviewMapControlOptions: false,
             }).goomaps("addmarkers", [{ options: {
                    position: [51.462998,-0.010772]

                    
             }}]);         
          });
         </script>

    </body>
    </html>
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  8. #33
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hmm this is what happened before when I tried to add similar code, - the page is now not displayed, - just a blank white page...

  9. #34
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lee_sov View Post
    Hmm this is what happened before when I tried to add similar code, - the page is now not displayed, - just a blank white page...
    After submitting the form?

    Add
    PHP Code:
    ini_set('display_errors'1); 
    To the top of your script
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  10. #35
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, I cant even access the page now to fill in the form, made changes, uploaded, refreshed page and nothing, just blank white page

  11. #36
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Do you have access to error logs? If so, look in there for why it is showing a blank page.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  12. #37
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No I don't have access to the logs. As soon as I add that phpMailer code in, the page is blank. Take it out & its all ok again!

  13. #38
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    try commenting out the include_once line and see if the blank page happens
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  14. #39
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    its the $mail->Username = and $mail->Password = lines that are casuing the problem, - the page is fine if I connect these two out, add them back in & its blank!

  15. #40
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    hmm... I got that from your hosts example, weird... so I'd ask them about it. Also, you should ask them about access to error logs, as you should have the ability to view those.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  16. #41
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    OK I've realised the issue, those two lines were missing the ; at the end of each one. the page now loads then I get another page after submitting the form 'Attempting to send e-mail...' but that's all it goes no further

  17. #42
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    I had commented that out, but chances are you are still getting an error of some sort. Try using the following:
    PHP Code:
      try {
        include_once(
    'class.phpmailer.php');
        
    $mail = new PHPMailer(true);
        
    $mail->IsSMTP();
        
    $mail->Host ""// place your smtp host here
        
    $mail->SMTPAuth true;
        
    $mail->Username ""// place your smtp username here
        
    $mail->Password ""// place your smtp password here

        
    $mail->From $_POST["email"];
        
    $mail->FromName $_POST["name"];
        
    $mail->AddAddress("enquiries@.co.uk");

        
    $mail->Subject "Enquiry from the  Website";

        
    // build the email
        
    $s "The following contact form has been submitted:\n\n";

        
    $s .= "=== Customer Details =====\n";
        
    $s .= "Name: " .$_POST["name"]. "\n";
        
    $s .= "Company: " .$_POST["company"]. "\n";
        
    $s .= "Telephone: " .$_POST["telephone"]. "\n";
        
    $s .= "Email Address: " .$_POST["email"]. "\n\n";

        
    $s .= "=== Enquiry Information =====\n";
        
    $s .= trim($_POST["comments"])."\n\n";

        
    $s.= "Generated: " .date("Y-m-d H:i:s");

        
    $mail->Body $s;
        
    $mail->WordWrap 72;

    //    echo "Attempting to send e-mail...";
        
    if ($mail->Send()) {
            
    $SENT true;
    //        echo "Success!";
        
    } else {
            
    $SENT false;
    //        echo "Failed!";
        
    }
      } catch (
    phpmailerException $e) {
        echo 
    $e->errorMessage();
      } catch (
    Exception $e) {
        echo 
    $e->errorMessage();
      } 
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  18. #43
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Now I get a period of the page reloading (10 secs maybe) then goes back to the contact page with the original error there was a problem sending the form...

    If I uncomment out the quotes, I receive Attempting to send e-mail...Failed!

  19. #44
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    I'm going to assume the username and password are correct (along with the Host) as that should have generated a specific type of error. So I'd take a look at
    PHP Code:
    $mail->AddAddress("enquiries@.co.uk"); 
    That doesn't look like a valid e-mail address.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  20. #45
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I have just deleted the domain from that E-mail address, - the actual address is correct in my uploaded script. Could there be something missing in the code that's causing it not to send? I noticed the following in the sample script from the host:

    // Send Message and Report
    if(!$mail->Send()) { echo "Message could not be sent.
    "; echo "Mailer Error: " .
    $mail->ErrorInfo; exit; } echo "Mail was sent thank you!"; echo sprintf("
    Go Back ",$_SERVER['HTTP_REFERER']); ?>

  21. #46
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok so ive managed to get this working by creating a pop email address on the host & using that. I cannot get it to send to their server direct though as I would like, - when I change the E-mail address to one of their own on their mail server, the email fails to send!?

  22. #47
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If you're using SMTP Authentication (which you appear to be) then the email address, username and password for the sending account must exist. You also must have permission to send (ie host or port isn't blocked somewhere along the line)

  23. #48
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The E-mail account I want to use does exist, its just not setup on the host as they are using mx records & have their own mail server. As I say I can create a temporary pop account on the host & it works fine, but obviously its just not sending to the right address!

  24. #49
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Them having their own MX records and mail server shouldn't matter. The web server should be connecting to an SMTP server that you specify and just sending the email direct to there. The MX record shouldn't make any difference at this point. It's after you've connected to the SMTP server and delivered the email that the MX server will even be looked up, and that would be by the SMTP server itself, not the webserver that is sending the mail.

    For example, if you're sending to antnee@mydomain.com, you may have the following configuration:
    • SMTP server: smtp.yourdomain.com
    • SMTP username: youruser
    • SMTP password: yourpass
    • SMTP authentication: TRUE
    • SMTP secure: FALSE


    So, your mailer code knows that it needs to connect to smtp.yourdomain.com and to authenticate using the username and password. The email will have a to-address of antnee@mydomain.com. The SMTP server should accept this as you've successfully authenticated. It should not fail at this point.

    What happens next is that it looks at the to-address, and picks out the domain, ie mydomain.com. It now needs to look for an MX record in the DNS for mydomain.com, and not for yourdomain.com. It would hopefully find something like mx1.mydomain.com and the SMTP server would send the mail via this exchanger. Your webserver is not a part of this loop at all. If that fails (mailbox doesn't exist, quota full etc) it will return an error to the SMTP server, which will usually keep retrying until eventually it gives up and sends an email to your return email address, which if not set explicitly will be something like webmaster@serverhost.com

    So, unless my understanding of the mail system is completely flawed, I'm not sure how them having their own mail server and MX records will be the problem. It's more likely that you've not authenticated correctly, and that could be username, password, whether authentication is even required or not, if you need to be using a secure connection and which port you should connect to the SMTP server on (they're not always on the port you expect).

  25. #50
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok so it looks like I'm currently setting this up with an email address & credentials from the webhost (eurofasthost) rather than the actual server which I guess is why its not working.

    The problem is when I put the server details in, its not working but I don't know why. We have an A record setup on the host pointing to our static IP address which is mail.ourdomain.co.uk, so I'm assuming that would be the smtp host. We use a Windows SBS server with Exchange so I've set the host as mail.ourdomain.co.uk, and then used one of our E-mail addresses setup on the server for authentication (enquiries@ourdomain.co.uk). this is the setup that's not working & I don't know why, - should I be using different ports for this or some kind of different authentication?

    I can access Outlook web access by typing https://mail.ourdomain.co.uk/exchange so that bits all working but I just cant figure out what else needs to be changed. All E-mails in & out of the server are also scanned by a 3rd party spam washer company, so we use an smtp smarthost but that shouldn't have any effect should it?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •