0  0 2017-02-28 08:54:42

PHP mailer is a library made for sending emails from web applications. The PHP mailer uses PHP as a platform for sending emails. It prevents from Email injection and spamming. From 2001 PHPMailer is one of the popular solutions for these matters on PHP. It was written by  Brent R. Matzelle in 2001.
You can use any functionality of SMTP-based e-mail, multiple recepients via to, CC, BCC, etc. PHPMailer is an efficient way to send e-mail within PHP. With PHPMailer  provides facility to use your own SMTP server and avoid Sendmail routines used by the mail() function on Unix platforms.

The PHP mail() function has some limitations and problems due to which PHP mailer is more popular compared with mail() function. Hence these problems can be avoided by using PHP mailer.

How to use PHP mailer:
1) Install PHP mailer in your project folder.
2) You can verify that you have successfully installed a PHP mailer you can use following code to check it:
    require 'PHPMailerAutoload.php';
    $mail = new PHPMailer;

3) Save it as a PHP document in the same directory where you've saved class.phpmailer.php
4) If no errors result occur from running the script, your installation has been done correctly.
5) require 'PHPMailerAutoload.php'; loads an autoloader that knows how to load the other classes used by PHPMailer; $mail = new PHPMailer; creates a new instance of the class as $mail;
6) There are many ways to send an email through PHP mailer
7) You will require a working local mail server.
8) The necessary information to send your first e-mail, use that information in place of the sample information provided here:

require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('', 'Your Name');
$mail->addAddress(', 'My Friend');
$mail->Subject  = 'First PHPMailer Message';
$mail->Body     = 'Hi! This is my first e-mail sent through PHPMailer.';
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
} else
    echo 'Message has been sent.';

Following is the description of above code:
$mail->setFrom('', 'Your Name');

Enter the address that the e-mail should appear to come from.

$mail->addAddress('', 'My Friend');

Email address to whom the email is to be sent.
Finally, we send out the e-mail, once all necessary information has been provided. This is done with $mail->Send();


Comments (0)

Post Your Comments


Hong Kong Office

Find Us On

Website Development Company
Digital Marketing
website development company in Hong Kong
website designer in pune