Free SMTP Mail Server for Your Web Application.
Wall Script
Wall Script
Friday, April 09, 2010

Free SMTP Mail Server for Your Web Application.

How to configure free SMTP mail server to your web project with Gmail account. I had implemented at 9lessons labs to sending email notifications using my gmail account. I did this with support of postageapp.com - the easier way to send email from web applications. It is simple and very easy to configure so use it and add email support to your web application.

Eg:labs.9lessons.info - Email notifications forgot password, comments and connecting friend.
Free SMTP Connect

First you have to create account at postageapp.com. The next thing you have to create a project.

postageapp_cofig.php
Here you have to add project API key.
<?php
# Setup Postage configuration
if(!defined('POSTAGE_HOSTNAME')) define ('POSTAGE_HOSTNAME', 'http://api.postageapp.com');
if(!defined('POSTAGE_API_KEY')) define ('POSTAGE_API_KEY', 'your project API key');
?>

Free Gmail SMTP Mail Server Configuration
Click -> Add mail servers - to configure with your Gmail username and password.
Free SMTP Connect

9lessons labs mail server report
Postageapp.com is an email management application.
Free SMTP Connect

Postageapp PHP source download files : Postageapp PHP example

postageapp_class.php
<?php
require_once('postageapp_config.php');

class PostageApp
{
// Sends a message to Postage App
function mail($recipient, $subject, $mail_body, $header, $variables=NULL) {
$content = array(
'recipients' => $recipient,
'headers' => array_merge($header, array('Subject' => $subject)),
'variables' => $variables,
'uid' => time()
);
if (is_string($mail_body)) {
$content['template'] = $mail_body;
} else {
$content['content'] = $mail_body;
}
return PostageApp::post(
'send_message',
json_encode(
array(
'api_key' => POSTAGE_API_KEY,
'arguments' => $content
)
)
);
}
// Makes a call to the Postage App API
function post($api_method, $content) {
$ch = curl_init(POSTAGE_HOSTNAME.'/v.1.0/'.$api_method.'.json');
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
}
}
?>

SMTPtest.php
Sample page to sending test email. More information please visit postageapp.com
<?php
require_once('postageapp_class.php');
if($_POST['to'])
{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mail_body = array(
'text/plain' => $message,
'text/html' => $message
);
$ret = PostageApp::mail($to, $subject, $mail_body);

}
?>

<form method="post" action="">
to:<input type="text" name="to" /><br/>
sub:<input type="text" name="subject" /><br/>
message:<textarea name="message" ></textarea><br/>
<input type="submit" value="Send"/>
</form>
web notification

13 comments:

  1. hey!! amazing thx!! bit question buddy what tool u use for create the first image diagram (postage.png) have a nice day

    ReplyDelete
  2. I did not know postageapp.com. Thank you.

    Regarding using google as smtp, please note that they limit how many mails you can send pr day. As far as I remember the limit is 500 pr. day for free accounts.

    ReplyDelete
  3. teşekkürler dersiniz için

    ReplyDelete
  4. why when i send the email....the subject didn't come out? the subject will be empty...

    instead of get the subject from POST i'm also try to set the subject manually like this but still cannot work..

    if($_POST['to'])
    {
    $to = $_POST['to'];
    $subject = "Membership Activation";
    $message = $_POST['message'];
    $mail_body = array(
    'text/plain' => $message,
    'text/html' => $message
    );
    $ret = PostageApp::mail($to, $subject, $mail_body);

    }

    ReplyDelete
  5. I use the phpMailer Class. So I connect directly to Gmail when coding and just comment a few lines when online.
    I hope you find this usefull.

    $mail = new PHPMailer();
    $mail->IsSMTP(); // send via SMTP
    IsSMTP(); // send via SMTP
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "[email protected]"; // SMTP username
    $mail->Password = "password"; // SMTP password
    $mail->From = $webmaster_email;
    $mail->AddAddress($email,$name);
    $mail->AddReplyTo($webmaster_email,"Webmaster");
    $mail->Subject = "This is the subject";
    $mail->Body = "Hello, World";
    $mail->Send();

    Download:
    http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/

    Great blog by the way.

    ReplyDelete
  6. I want to create one for my site to deliver updated look nice i will try

    ReplyDelete
  7. very nice tutorial.., usefull to me.. thanks

    ReplyDelete
  8. superb post. good work..

    http://www.itechaleart.com/

    ReplyDelete
  9. we can use this method from XAMP localhost?

    ReplyDelete
  10. I got this error how can i rectify it.

    Undefined variable: HTTP_HOST in C:\wamp\www\mail1\SMTPclass.php on line 30

    ReplyDelete
  11. how to configure SMTP in gmail account?? can we use this code from XAMP localhost???

    ReplyDelete

mailxengine Youtueb channel
Make in India
X