How to apply SMTP Authentication to my mail?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simon2x1
    New Member
    • Dec 2008
    • 123

    How to apply SMTP Authentication to my mail?

    The code below is my mail code that send passsword to mail
    but it does not go to yahoo and gmail i want to add STMP
    authentication to it how can i do that.

    Code:
    <?php
    		if(isset($_POST['submit'])){
    	If(empty($_POST['email'])) {
    	echo 'Please fill in the required fields!';
    	
    		}else{
    			
    			$email_to = $_POST['email'];
    			$sql = "SELECT statue FROM statue WHERE mail='$email_to'";
    			$result = mysql_query($sql);
    			
    				$count=mysql_num_rows($result);
    				if($count==1){
    				$rows = mysql_fetch_array($result);
    				$your_password = $rows['statue'];
    
    			$to = $email_to;
    			$subject = "Your password here";
    			$headers  = 'MIME-Version: 1.0' . "\r\n";
    			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    			$headers .="from: Alinke <support@mydomain.com>";
    			
    
    				$messages ="Here is your password : $your_password";
    				$sentmail = mail($to,$subject,$messages,$headers);
    				}else{
    				echo 'your email can not be found in our database';
    			}
    			
    				if($sentmail){
    					echo 'Your password has been sent to your email address.';
    				}else{
    					echo 'Cannot send password to your e-mail address';
    				}
    		}
    	}
    
    ?>
  • simon2x1
    New Member
    • Dec 2008
    • 123

    #2
    what if i do it like this will it work
    Code:
      <?php
             if(isset($_POST['submit'])){
         If(empty($_POST['email'])) {
         echo 'Please fill in the required fields!';
      
             }else{
      
                 $email_to = $_POST['email'];
                 $sql = "SELECT statue FROM statue WHERE mail='$email_to'";
                 $result = mysql_query($sql);
      
                     $count=mysql_num_rows($result);
                     if($count==1){
                     $rows = mysql_fetch_array($result);
                     $your_password = $rows['statue'];
      	
    
                 $subject = "Your password here";
                 $headers  = 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                 $headers .="from: Alinke <support@mydomain.com>";
      	
    host = "mail.mymail.com";
     $username = "smtp_username";
     $password = "smtp_password";
     
     $headers = array ('From' => $from,
       'To' => $to,
       'Subject' => $subject);
     $smtp = Mail::factory('smtp',
       array ('host' => $host,
         'auth' => true,
         'username' => $username,
         'password' => $password));
     
     $mail = $smtp->send($to, $headers, $body);
                 $to = $email_to;
      
                     $messages ="Here is your password : $your_password";
                     $sentmail = mail($to,$subject,$messages,$headers);
                     }else{
                     echo 'your email can not be found in our database';
                 }
      
                     if($sentmail){
                         echo 'Your password has been sent to your email address.';
                     }else{
                         echo 'Cannot send password to your e-mail address';
                     }
             }
        }
      
     ?>

    Comment

    Working...