Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

PHP Mailer not working

$
0
0
I am using PHP Mailer to send emails. It worked fine in the localhost. But, it's not working in live server. Here is my code. Please help me to figure out what the actual problem is. Here's my code. Any help will be highly appreciated.

require_once('phpmailer/class.phpmailer.php');
function sendMail($order_id){
		
		$query = "SELECT first_name,last_name,email from order_address WHERE order_id='".$order_id."' AND s_id='".$_SESSION['customer_id']."' AND title='B'";
		$result = mysql_query($query) or die(mysql_error());
		if(mysql_num_rows($result)==1){
			$row = mysql_fetch_assoc($result);
			$name = $row['first_name']." ".$row['last_name'];
			$to = $row['email'];
			$subject = "Message Subject";
			$message = "Message Body";
			
			$mail = new PHPMailer();  
 
			$mail->IsSMTP();
			$mail->isHTML(true);
			$mail->Mailer = "smtp";
			$mail->Host = "ssl://smtp.gmail.com";
			$mail->Port = 465;
			$mail->SMTPAuth = true; // turn on SMTP authentication
			$mail->Username = "username@gmail.com"; // Entered a valid Gmail address
			$mail->Password = "validpassword"; // Entered a valid password
			 
			$mail->From     = "username@gmail.com"; //$mail->Username and $mail->From are same
			$mail->FromName = "From Name";
			$mail->AddAddress($to);  
			 
			$mail->Subject  = $subject;
			$mail->Body = $message;
			$mail->WordWrap = 50;  
			 
			if(!$mail->Send()) {
				
				return false;
			} 
			else {
				
				return true;
			}
			
		}
		else{
			return false;
		}
		
	}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>