Annunci
RSS

Send Mail using PHP , EasyPHP and Gmail

26 Mar

To run this example you have to :

  • Install EasyPHP
  • Download PHPMailer https://github.com/Synchro/PHPMailer
  • Put the PHPMailer folder inside the PHP installation folder, in my case C:\Program Files\EasyPHP12.1\php\
  • Modify Some parameters in PHP Configuration file (php.ini) 
    • insert this line include_path = “.;${path}\php\phpmailer”
    • set smtp_port = 465
    • SMTP = smtp.gmail.com
    • and uncomment this line extension=php_openssl.dll

After tha Create email.php and put it in your WWW root folder

<?php
require(“phpmailer/class.phpmailer.php”);
$mail = new PHPMailer();
$mail->IsSMTP();

//GMAIL config
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = “ssl”; // sets the prefix to the server
$mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = “put ur gmail account here”; // GMAIL username
$mail->Password = “ur email password”; // GMAIL password
//End Gmail

$mail->From = “ur gmail account again”;
$mail->FromName = “name”;
$mail->Subject = “some subject”;
$mail->MsgHTML(“the message”);

//$mail->AddReplyTo(“reply@email.com”,”reply name”);//they answer here, optional
$mail->AddAddress(“destination email address”,”name to”);
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {//to see if we return a message or a value bolean
echo “Mailer Error: ” . $mail->ErrorInfo;
} else echo “<script>alert(‘Email sent’)</script>”;
// echo “Message sent!”
?>

 Test the page using the following URL : http://localhost:8080/email.php
if you get this message, then you have successfully sent your email

 

 

PHPMail

 

Annunci
 
Lascia un commento

Pubblicato da su marzo 26, 2013 in Programming

 

Tag: ,

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

 
%d blogger hanno fatto clic su Mi Piace per questo: