  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                ไฟล์ sendmail.php 
 
<? 
require "class.phpmailer.php"; 
 
function scriptdd_sendmail($to_name,$to_email,$from_name,$email_user_send,$email_pass_send,$subject,$body_html,$body_text) { 
 
$mail = new PHPMailer(); 
$mail -> From     = $email_user_send; 
$mail -> FromName = $from_name; 
 
$mail -> AddAddress($to_email,$to_name); 
$mail -> Subject	= $subject; 
$mail -> Body	= $body_html; 
$mail -> AltBody	= $body_text; 
$mail -> IsHTML(true); 
$mail -> SMTPSecure='ssl' 
 
$mail -> Mailer = "smtp"; 
$mail -> IsSMTP(); 
$mail -> Host = 'smtp.gmail.com'; 
$mail -> Port = 465; 
$mail -> SMTPAuth 	= true; 
//$mail->SMTPDebug= true; 
$mail -> Username 	= $email_user_send; 
$mail -> Password 	= $email_pass_send; 
 
$mail->Send(); 
$mail->ClearAddresses(); 
 
} 
 
$to_name	 ="tai"; 
$to_email	 ="[email protected]"; 
$from_name ="tai"; 
$email_user_send	="[email protected]"; 
$email_pass_send	=".............."; 
$subject		="Test send mail"; 
$body_html	="<img src='http://www.greenlatex.com/images/logo.jpg'>"; ลิ้งค์รูปใน host 
$body_text	="ข้อความ"; 
 
scriptdd_sendmail($to_name,$to_email,$from_name,$email_user_send,$email_pass_send,$subject,$body_html,$body_text); 
 
echo "complete"; 
 
?>ส่วนใน file class.phpmailer.php กับ class.smtp.php ผมทำการแก้ port เป็น 465 ครับ 
 
 
มันดันขึ้น EROR ว่า SMTP Error: Could not connect to SMTP host. complete
 
 
  Tag : PHP               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2011-03-10 21:17:47 | 
                      By :
                          small_rabbit | 
                      View :
                          1390 | 
                      Reply :
                          1 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |