batty
batty

Reputation: 597

Send and receive emails from localhost using PHP running XAMPP

I am trying to make an application which can parse emails and update the database. I tried to set up the localhost to send and receive emails so that I can carry on from there. I am unable to do that. I tried configuring Outlook, Thunderbird to set up local email system using mercury mail server. Its not working properly.

I would like to have a step by step procedure explaining how to make this work.

Upvotes: 2

Views: 8055

Answers (5)

sagivasan
sagivasan

Reputation: 97

hi try this it will work..... download phpmailer.zip github.com/PHPMailer/PHPMailer

simple code for send mail:

<?php
    require 'PHPMailerAutoload.php';

    $mail = new PHPMailer;

    $mail->isSMTP();                                      
    $mail->Host = 'smtp.gmail.com'; 

    $mail->SMTPAuth = true;                             
    $mail->Username = '[email protected]';                           
    $mail->Password = 'ur password';                           
    $mail->SMTPSecure = 'tls';                          
    $mail->From = '[email protected]';
    $mail->FromName = 'mailer';
    $mail->addAddress('[email protected]');  
    $mail->addAddress('[email protected]');             
    $mail->addCC('[email protected]');
    $mail->addBCC('[email protected]');
    $mail->WordWrap = 50;                                
    $mail->isHTML(true);                                 
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';

    if(!$mail->send()) {
       echo 'Message could not be sent.';
       echo 'Mailer Error: ' . $mail->ErrorInfo;
       exit;

}
?>

Upvotes: 1

Ruwantha
Ruwantha

Reputation: 2653

I found a easy solution for this try this application http://smtp4dev.codeplex.com/

Upvotes: 0

8bitme
8bitme

Reputation: 947

You could try configuring a local mail server that allows you to sent to and receive from localhost.

Have a look at this link on how to set this up

Upvotes: 0

AlexV
AlexV

Reputation: 23098

For sending emails via SMTP in PHP you only have to change SMTP = localhost in the [mail function] section of PHP.INI to the SMTP of your ISP. Also you need to change the port for some ISPs that block the default port (25). Exemple:

[mail function]
SMTP = mail.mydomain.com
smtp_port = 2525

Upvotes: 0

Related Questions