I have been working with labs.9lessons application hosted at Amazon Web Services. Few days back I had enabled email notification system using Amazon Simple Email Service SMTP implemented with PHP Mailer class, I hope the following tutorial will help you to enable email notification system for your web projects.

Download Script
Live DemoThe tutorial contains five PHP files in that three are PHPmailer files other SMTP config files.
class.phpmailer.php // PHP Mailer library
class.smtp.php
class.pop3.php
Send_Mail.php // SMTP configer
index.php // Start Page
class.smtp.php
class.pop3.php
Send_Mail.php // SMTP configer
index.php // Start Page
Send_Mail.php
Here you have to give Amazom SES SMTP credentials.
<?php
function Send_Mail($to,$subject,$body)
{
require 'class.phpmailer.php';
$from = "from@email.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Mailer = "smtp";
$mail->Host= "tls://email-smtp.us-east.amazonaws.com"; // Amazon SES
$mail->Port = 465; // SMTP Port
$mail->Username = "Amazon SMTP Username"; // SMTP Username
$mail->Password = "Amazon SMTP Password"; // SMTP Password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from,'9lessons Labs');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
if(!$mail->Send())
return false;
else
return true;
}
?>
function Send_Mail($to,$subject,$body)
{
require 'class.phpmailer.php';
$from = "from@email.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Mailer = "smtp";
$mail->Host= "tls://email-smtp.us-east.amazonaws.com"; // Amazon SES
$mail->Port = 465; // SMTP Port
$mail->Username = "Amazon SMTP Username"; // SMTP Username
$mail->Password = "Amazon SMTP Password"; // SMTP Password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from,'9lessons Labs');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
if(!$mail->Send())
return false;
else
return true;
}
?>
index.php
Here called Send_Mail function and passing to, subject and body values.
<?php
require 'Send_Mail.php';
$to = "to@gmail.com";
$subject = "Test Mail Subject";
$body = "Hi<br/>Test Mail<br/>Amazon SES"; // HTML tags
Send_Mail($to,$subject,$body);
?>
require 'Send_Mail.php';
$to = "to@gmail.com";
$subject = "Test Mail Subject";
$body = "Hi<br/>Test Mail<br/>Amazon SES"; // HTML tags
Send_Mail($to,$subject,$body);
?>
GMail SMTP
You have to modify following line in above Send_Mail.php code, gmail allow per day only 250 mail limit.
$mail->Host= "tls://smtp.gmail.com"; // GMail SMTP
$mail->Port = 465; // SMTP Port
$mail->Username = "Username@gmail.com"; // SMTP Username
$mail->Password = "Gmail Password"; // SMTP Password
$mail->Port = 465; // SMTP Port
$mail->Username = "Username@gmail.com"; // SMTP Username
$mail->Password = "Gmail Password"; // SMTP Password







Hey! Nice Mailer Post
Simple yet powerful, great tutorial thank you srinivas :)
nice info ..thanks for sharing...
How to get the SMTP username and password
This is pretty awesome
it been long you update blog? last time i using your facebook script for my tin tuc news website.. and it work perfect ..
for this email script .. is there any limitation of volume we can sent email out ?
thanks
I used this as an function so i could dynamically use it in my other pages.
I can always give an example of how i did that if people want.
only by using:
mail=new mail();
registration->($from,$subject,$body,$to);
I made on with an array function wo str_recplaces tekst in the body so people could use custom tags like [USER] in the $body=array()
Great post once again Sri. Keep up the good work!
Nice One
is this work $mail->SetFrom($from, 'From Name');
when i used it take name of the email id not taking underspecified name
thanks for this toturial
hey post something new :P
Awesome, I am agree with the view of Jonathan that mail=new mail();
registration->($from,$subject,$body,$to);
I made on with an array function wo str_recplaces tekst in the body so people could use custom tags like [USER] in the $body=array()
nice tutorial dude
Awesome
Hi
Please help me I am trying set this up,
this is my Send_Mail.php
IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Mailer = "smtp";
$mail->Host = "tls://email-smtp.us-east-1.amazonaws.com"; // Amazon SES server, note "tls://" protocol
$mail->Port = 465; // set the SMTP port
$mail->Username = "AKIAJ3S57QUFQKS4A7VQ"; // SES SMTP username
$mail->Password = "Avl2i0lbSlC9ZSw2l7477f0urgC/AyZNkZ51r7sQrEF/"; // SES SMTP password
$mail->SetFrom($from, 'yuvraj61184@gmail.com');
$mail->AddReplyTo($from,'yuvraj61184@gmail.com');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
if(!$mail->Send()){
return "failed";
}
else{
return "success";
}
this is my index.php
I have created an account with amazon ses and taken the smtp credentials.
I have a godaddy hosting, and I have added SPF record : v=spf1 mx include:amazonaws.com include:amazonses.com ~all
how to fix this and where can I see the error logs?
But I am unable to send the mail, can you please guide me its urgent
Hello
I am using this script on normal web hosting its working.
same script i am using on my VPS its not working.
may i know anything i need to do for this script in my vps??
Please help me ASAP.
Thank you.
What's the windows live smtp?
Everyone collaborated well. Hats off to all.