#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0

    Question Help - php contact form w/smtp


    Hi there,

    PLEASE HELP!!!

    I have no idea how php codes work and as a result the only way I can create a php contact form with smtp auth. was to assimilate existing codes by others to fit into the one I am using right now. I hope thats ok. I know what I am doing is probably the most basic of php and is of no sweat to most of you BUT that is just my level of understanding php here. So if you could give me some tips and help I would really appreciate it.


    Transferring php contact form w/smtp auth. codes to host server that is using IIS

    I had transferred the the php contact form to the host that is using IIS ( I have no idea what it is). I had also transferred the mail.php and some other "pear" files to the host server on the same folder.
    When submitting the contact form :
    * There wasn't any error message given just the date shown and nothing else.
    * The ""Attempting to send email" also wasn't shown.
    * There wasn't any email sent.


    What did I missed out?

    * did I missed out on some important codes in the php file?
    * does IIS using the same php codes as below?
    * any other input is very much appreciated.



    The php contact form with smtp codes are as follow :



    <?php
    $errors = '';

    if(empty($_POST['firstName'])||

    empty($_POST['lastName']) ||

    empty($_POST['phoneNumber'])||

    empty($_POST['eMail'])||

    empty($_POST['enquiry'])
    )

    {
    $errors .= "\n Error: indicates required fields";
    }

    $first_name = $_POST['firstName'];
    $last_name = $_POST['lastName'];
    $phone_number = $_POST['phoneNumber'];
    $email_address = $_POST['eMail'];
    $enquiry = $_POST['enquiry'];
    $message = $_POST['message'];

    if (!preg_match(

    "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",

    $email_address))

    {
    $errors .= "\n Error: Invalid email address";
    }



    require_once "Mail.php";


    $from = "*****@gmail.com";
    $to = "*****@gmail.com";
    $subject = "Inquiries ( $enquiry)";
    $timezone = "EU";
    if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
    echo date ("D, M j, Y - H:i:s .............");
    $date = date ("D, M j, Y - H:i:s");

    $body = "You have received a Web Enquiry. It was submitted on $date \n
    Name : $first_name\n
    Last Name : $last_name\n
    Contact : $phone_number\n
    Email : $email_address\n
    Enquiry Type: $enquiry\n
    Comments :\n\n $message";

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "*****@gmail.com";
    $password = "*****";


    $headers = array('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    echo("<p>Attempting to send email ....</p>");

    if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
    } else {
    echo("<p>MESSAGE SUCCESSFULLY SENT!</p>");
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,464
    Rep Power
    594
    I suggest you start here.

    P.S. Please read the sticky at the top of this forum that says READ THIS BEFORE POSTING and edit your original post to comply.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0

    Post


    Originally Posted by gw1500se
    I suggest you start [*=(* address blocked: See forum rules)/manual/en/tutorial.php]here[/*].

    P.S. Please read the sticky at the top of this forum that says READ THIS BEFORE POSTING and edit your original post to comply.
    Thanks for the links it helped. I just found out that the host server is using PHP version 3.0. THEY CONFIRMED IS NOT VERSION 3.0 BUT 5.2 ACTUALLY.

    Looks like I have to downgrade my php file by two versions ....Is it even possible???

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    correct term is UPGRADE
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by paulh1983
    correct term is UPGRADE
    Are my php codes even compatible to php version 5.2 (not 3.0) and if not how do I get it to work with version 5.2?
    I have searched but nothing is helping and I need ....
    HELP.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,464
    Rep Power
    594
    In general it will be upward compatible. However, there are certain features that might be unavailable. In any case, if your code is written for 3.0 then you definitely need to review all your code and modify it, particularly from a security standpoint, to use modern practices.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    if you can get the latest version on your local machine then you can run your website there and see if you get any errors and then go from there. (make sure error reporting is ON for everything)

    You can also look at php change logs to see what things were removed/added/modified but this may take a long time so i would do my first suggestion.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by gw1500se
    In general it will be upward compatible. However, there are certain features that might be unavailable. In any case, if your code is written for 3.0 then you definitely need to review all your code and modify it, particularly from a security standpoint, to use modern practices.
    the codes worked on wampserver with PHP 5.3.10 though - I was able to send and receive emails. I am not sure if wampserver is of any legit to gauge anything at all.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by paulh1983
    if you can get the latest version on your local machine then you can run your website there and see if you get any errors and then go from there. (make sure error reporting is ON for everything)

    You can also look at php change logs to see what things were removed/added/modified but this may take a long time so i would do my first suggestion.
    I used wampserver w/PHP5.3.10 - with pear package and was able to send email with no error. However my server host only uses PHP 5.2 version though so how is it that I couldn't send anything at all?

    I have searched with no avail how to turn on error reporting do you. I confessed that I have read the sticky and I understood but .....
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    well make sure that your wamp mirrors exactly what your host has, there is no point checking on php 5.6 for example when most hosts havent got it?

    regarding not being able to send email, you can try using google smtp. Looks like your host doesnt have this enabled. i would contact them first
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by paulh1983
    well make sure that your wamp mirrors exactly what your host has, there is no point checking on php 5.6 for example when most hosts havent got it?

    regarding not being able to send email, you can try using google smtp. Looks like your host doesnt have this enabled. i would contact them first
    These are the server details my host uses.
    Webserver : IIS 6
    SQL Server : MySQL 5
    Bandwidth : Unlimited Bandwidth (Best effort basis)
    Disk Space : 10GB
    Email Account Disk Space : 1GB for each account by default.
    Coding Language Supported : PHP5.2/ASP.net/ASP/HTML/Flash/Javascripting
    Internet Connection Speed : Up to 155Mbps (Shared) as in 15MBps.

    I have tried with my host's provided email, gmail and yahoo and they all worked on the wamp ....

    I am now one big confused novice coder ..
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    7
    Rep Power
    0
    Originally Posted by paulh1983
    well make sure that your wamp mirrors exactly what your host has, there is no point checking on php 5.6 for example when most hosts havent got it?

    regarding not being able to send email, you can try using google smtp. Looks like your host doesnt have this enabled. i would contact them first
    I got it figured out!
    I got it figured out!


IMN logo majestic logo threadwatch logo seochat tools logo