web 2.0

How to use PHP & Send Email Using Gmail Authentication

How to use PHP & Send Email Using Gmail Authentication This the tutorial/example a scripts how to use PHP and send mail/email Using Gmail Authentication from php Scirpt.

ShotDev Focus:
- PHP & Send Mail (Using Gmail Authentication)

Example

php_sendmail_gmail.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "myaccount@gmail.com"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
$mail->From = "webmaster@shotdev.com"; // "name@yourdomain.com";
//$mail->AddReplyTo = "support@shotdev.com"; // Reply
$mail->FromName = "Mr.Weerachai Nukitram";  // set from Name
$mail->Subject = "Test sending mail.";
$mail->Body = "My Body & <b>My Description</b>";

$mail->AddAddress("email@hotmail.com", "Mr.Adisorn Boonsong"); // to Address

$mail->AddAttachment("shotdev/myfile.zip");
$mail->AddAttachment("shotdev/myfile2.zip");

//$mail->AddCC("member@shotdev.com", "Mr.Member ShotDev"); //CC
//$mail->AddBCC("member@shotdev.com", "Mr.Member ShotDev"); //CC

$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low

$mail->Send();
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_sendmail_gmail.php

Screenshot

PHP Send Mail (Using Gmail Authentication)

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.