How to configure with Gmail phpMailer
Configure phpMailer to work using smtp and a Gmail account.
phpMailer gmail configuration
We use to meet with mail servers using the default port (25) for mail and do not use any encryption security. With gmail if we set this way, we will be unable to connect to the server and we will report errors. This is a sample configuration that we have to use phpmailer gmail account:
//Include the class phpmailer.php require_once("class.phpmailer.php"); //Instance an object of phpmailer $mail = new phpmailer(); //Indicate to phpmailer where is the smtp $mail->PluginDir = ""; //We will use smtp $mail->Mailer = "smtp"; //Our server smtp. The encryption is ssl $mail->Host = "ssl://smtp.gmail.com"; //Port of gmail 465 $mail->Port="465"; //Smtp requires authentication $mail->SMTPAuth = true; //Our username and password $mail->Username = "email@example.com"; $mail->Password = "xxxxxxxxx"; //Our email address and the name which will be displayed $mail->From = "firstname.lastname@example.org"; $mail->FromName = "Name of sender"; //The dafault value of Timeout is 10, we give a little more $mail->Timeout=30; //Indicates the receiver email $mail->AddAddress("email@example.com"); //Subject $mail->Subject = "Example from WikiCode"; //Body message. Can contains html $mail->Body = "My body"; //If dont supports html $mail->AltBody = "Only text"; //Send the email $result = $mail->Send(); //$result contains true or false as sent or found faulty.