phpMailer , a great Email transfer class .

21 08 2006

Saved me a lot of work really .

I was looking for a way to use an smtp server ( microsoft exchange server in my case ) with the mail() function in php & since exchange is involved that means SMTP authentication is requierd as (relay is turned off) .
I had many results after searching, such as pear and other classes .
But phpMailer was effective and easier to use, it also support attachments , embeding & HTML format .

http://phpmailer.sourceforge.net/

here is a simple usage :

<?php
require(“class.phpmailer.php”);
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = “EmailserverHost”; // SMTP server
$mail->SMTPAuth = true;
$mail->Username = ‘username’;
$mail->Password = ‘password’;

$mail->FromName = ‘Moody’;
$mail->From = “youremail@yoursite.com”;//sender addy
$mail->AddAddress(“tosomeone@hisSite.com”);//recip. email addy

$mail->Subject = “Your Subject”;
$mail->Body = “hi ! \nBLA BLA BLA !”;
$mail->WordWrap = 50;

if(!$mail->Send())
{
echo “Message was not sent”;
echo “Mailer Error: ” . $mail->ErrorInfo;
}
else
{
echo “Message has been sent”;
}
?>

More examples and tutorials can be found @ http://phpmailer.sourceforge.net/tutorial.html

Documentation @ http://phpmailer.sourceforge.net/docs/

Advertisements

Actions

Information

2 responses

9 01 2007
Oriol News Portal

phpMailer – una classe de PHP per enviar emails

En PHP quan s’ha d’enviar un email sovint s’usa la funciˇ mail() tot i que aquesta Ús una mica limitada en quan a parÓmetres que se li poden passar al servidor SMTP. Per exemple, temes d’autenticaciˇ…

30 12 2007

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: