PHPMailer is simple enough to use but in windows server you may face problem.because it is not same as we do.Check the following steps
1. Make a new folder 'includes' in your PHP installation folder.
Example (c:\php\includes)
2. You just need to upload PHPMailer class folder inside the 'includes' folder.
Example C:\php\includes\PHPMailer
3. Add this include path in your php.ini . commencement sendmail_path and use the path
Example sendmail_path ="C:\php\includes\PHPMailer\HPMailerAutoload.php"
So in php.ini file it will look like
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="C:\php-5.5.14\include\PHPMailer\HPMailerAutoload.php"
4. Also keep PHPMailer class folder in your root directory. use the class
Example
require 'class/PHPMailer/PHPMailerAutoload.php';
$from = "test@test.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com"; // SMTP host here use gmail
$mail->Port = 465; // set the SMTP port
$mail->Username = "test@gmail.com"; // SMTP username
$mail->Password = 'ur gmail pass'; // SMTP password
$mail->SMTPSecure = 'ssl';
$mail->SetFrom($from, 'Support Test');
$mail->AddReplyTo($from,'Support Test');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to, $to_name);
if($mail->Send())
{
echo "mail sent!!";
}
else echo "mail not sent!!";
1. Make a new folder 'includes' in your PHP installation folder.
Example (c:\php\includes)
2. You just need to upload PHPMailer class folder inside the 'includes' folder.
Example C:\php\includes\PHPMailer
3. Add this include path in your php.ini . commencement sendmail_path and use the path
Example sendmail_path ="C:\php\includes\PHPMailer\HPMailerAutoload.php"
So in php.ini file it will look like
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="C:\php-5.5.14\include\PHPMailer\HPMailerAutoload.php"
4. Also keep PHPMailer class folder in your root directory. use the class
Example
require 'class/PHPMailer/PHPMailerAutoload.php';
$from = "test@test.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com"; // SMTP host here use gmail
$mail->Port = 465; // set the SMTP port
$mail->Username = "test@gmail.com"; // SMTP username
$mail->Password = 'ur gmail pass'; // SMTP password
$mail->SMTPSecure = 'ssl';
$mail->SetFrom($from, 'Support Test');
$mail->AddReplyTo($from,'Support Test');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to, $to_name);
if($mail->Send())
{
echo "mail sent!!";
}
else echo "mail not sent!!";
No comments:
Post a Comment