Php Flow » Php

Send Mail Using Amazon Cloud Server With PHP

Hi Friends,
In this tutorial i will describe how to send mail using amazon server SMTP.The amazon cloud server does not allow PHP mail function so that your mail does not work on amazon cloud server. The amazon are providing PHP sdk for PHP mail. We will use php mailer class for send mail using SMTP.

Before use below code, you should be known about your SMTP user and password, because to configure SMTP we need STMP user name and password.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'class.phpmailer.php';

        $messageBody = "hello!";

        $from = 'from mail id';
        $mail = new PHPMailer();
        $mail->SMTPDebug = 2;
        $mail->IsSMTP(true); // SMTP
        $mail->SMTPAuth   = true;  // SMTP authentication
        $mail->Mailer = "smtp";
        $mail->Host       = "amazonaws.com"; // Amazon SES server, note  protocol
        $mail->Port       = 465;                    // set the SMTP port
        $mail->Username   = "";  // SES SMTP  username
        $mail->Password   = "";  // SES SMTP password
        $mail->SetFrom($from, 'from email id');
        $mail->AddReplyTo($from,'test');
        $mail->Subject = "test smtp";
        $mail->MsgHTML($messageBody);
        $address = 'tomail';
        $mail->AddAddress($address, 'tomail');
        try{
            $isSend= $mail->Send();
        if (!$isSend)
        {
             die('Sorry, message delivery failed. Contact webmaster for more info.');
        }

        }catch (Exception $e){
            echo $e->getMessage();die;
        }

Download script

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>