SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Threaded View

  1. #1
    SitePoint Enthusiast adamschroeder's Avatar
    Join Date
    Mar 2011
    Location
    World
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    email activation smtp authentication

    Hi ,
    I have this script through which I would like to send an automatic email to clients upon registration, but the email is never sent. I am using my hostmonster's Outgoing Mail Server: mail.ciudadanossinfronteras.com.
    However when I go into hostmonster and check email settings it says: Outgoing Mail Server: mail.ciudadanossinfronteras.com (server requires authentication) port 26.

    Can anyone let me know what I can do to authenticate my outgoing mail server?


    PHP script:
    PHP Code:
    <?php 
    include ('connection.php');
    if(
    $submit)


    {
      

    $username strtolower(strip_tags($_POST['username']));
    $password strip_tags($_POST['password']);
    $repeatpassword strip_tags($_POST['repeatpassword']);
    $firstname $_POST['inputfirstname'];
    $lastname $_POST['inputlastname'];
    $desc $_POST['inputdesc']; 
    $email $_POST['inputemail']; 
    $email_confirm $_POST['inputemail_confirmation'];
    $phone $_POST['inputphone']; 
    $skype $_POST['inputskype']; 
    $house $_POST['inputhousenumber']; 
    $street $_POST['inputstreet']; 
    $city $_POST['inputcity']; 
    $state $_POST['inputstate']; 
    $country $_POST['inputcountry']; 
    $status $_POST['inputstatus']; 
    $period $_POST['inputperiod']; 
    $field $_POST['inputfield'];
    $language $_POST['inputlanguage'];


    $errorstring "";

    //default value of error string 
    if (!$firstname ||(=== preg_match("/\S+/"$_POST['inputfirstname']))) $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Name<br></span>"
    if (!
    $lastname ||(=== preg_match("/\S+/"$_POST['inputlastname']))) $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Lastname<br></span>"
    if (!
    $email$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Email<br></span>"
    if (
    $status == "emergency"&& !$phone$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Phone number is required for emergency assistance <br></span>";
    if (
    preg_match('/[a-z]+/i'$_POST['inputphone'])) $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Phone number cannot contain letters<br></span>";
    if (!
    $desc$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Description<br></span>";
    if (
    $country=="---" || $country=="Africa" || $country=="Europe" || $country=="Central-America" || $country=="North-America" || $country=="South-America" || $country=="Asia" || $country=="Middle-East")
        
    $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Country<br></span>";
    if (!
    $language ||(=== preg_match("/\S+/"$_POST['inputlanguage'])))
        
    $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Languages spoken<br></span>";
    if (
    $field=="---"$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Field of interest<br></span>";
    if (
    $status=="---"$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Urgency of assistance<br></span>"
    if (
    $period=="---"$errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Period of time your information will stay posted<br></span>"
    if (
    !==strcmp($_POST['inputemail'], $_POST['inputemail_confirmation'])) $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Emails do not match.</span>"

    $namecheck mysql_query("SELECT username FROM mainweb WHERE username='$username'");
      
    $count mysql_num_rows($namecheck);

    if (!
    $count==0)
          
    $errorstring $errorstring."<span style='color: rgb(204, 0, 0);'>Username already taken!<br></span>";

    if(
    $username&&$password&&$repeatpassword)
      {
        if (
    $password==$repeatpassword)
        {
        if (
    strlen($username)>25)
                                 {echo 
    "Length of username is too long";}
           else {
          if (
    strlen($password)>25||strlen($password)<6)
                     {
                       echo 
    "password must be between 6 and 25 characters";
                     }
                            else
                            {
                              
    //register the user 


                                    //open database
                                       
    if ($errorstring!="")
    echo 
    "<u>Please fill out the following fields</u>:<br><br>$errorstring";

    else { 
    $password md5($password);
                       
    $repeatpassword md5($repeatpassword);
                       
    //generate random number for activation process
                         
    $random rand(23456789,98765432);

      
    mysql_query ("INSERT INTO mainweb (`id`,`date`,`firstname`,`lastname`,`description`,`email`,`phonenumber`,`skype`,`house`,`street`,`city`,`state`,`country`,`soa`,`periodoftime`,`field`,`languages`,`username`,`password`,`random`,`activated`)
                       VALUES(NULL,NOW(),'
    $firstname','$lastname','$desc','$email','$phone','$skype','$house','$street','$city','$state','$country','$status','$period','$field','$language','$username','$password','$random','0')") or die(mysql_error());

                     [
    COLOR="Red"$lastid mysql_insert_id();

                       
    //send activation email
                       
    $to $email;
                       
    $subject "Activate your account";
                       
    $headers "From: adamschroder@asia.com";
                       
    $server "mail.ciudadanossinfronteras.com";

                       
    ini_set("SMTP",$server);

                       
    $body="
                       Hello 
    $firstname,\n\n
                       You need to activate your account with the link below:/n/n
                       
                       http://ciudadanossinfronteras.com/activate.php?id=
    $lastid&code=$random
                       "
    ;
                      [/
    COLOR]
                       
    //function to send email
                       
    mail($to$subject$body$headers);

                       echo
    "<meta http-equiv='refresh' content='0;URL=http://ciudadanossinfronteras.com/thankyouhost.html' />"
         }

                            }

                }

        }
        else
            echo 
    "Your passwords do not match";

           }
      else
          echo 
    "Please fill out all necessary fields!";

    }
    ?>
    Last edited by SpacePhoenix; Mar 13, 2011 at 20:05. Reason: put php tags round php code to improve readability


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
  •