Created
June 25, 2013 07:38
-
-
Save tournasdim/5856680 to your computer and use it in GitHub Desktop.
Sending mail without attachment using the PHPMailer Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
First downlaod the library from Google | |
http://code.google.com/a/apache-extras.org/p/phpmailer/ | |
*/ | |
require_once 'class.phpmailer.php'; | |
$mail = new PHPMailer(true); | |
$to = "[email protected]"; | |
$subject = "this is a test from phpmailer" ; | |
$message = "This message was send with the PHP-mailer library and uses the defauld (mail) "; | |
try { | |
$mail->AddAddress($to, 'Example To'); | |
$mail->SetFrom('[email protected]', 'Example'); | |
$mail->AddReplyTo('[email protected]', 'Example'); | |
$mail->Subject = $subject; | |
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically | |
$mail->MsgHTML($message); | |
$mail->Send(); | |
echo "<p><br>Message Sent OK</br></p>"; | |
} catch (phpmailerException $e) { | |
echo $e->errorMessage(); //Pretty error messages from PHPMailer | |
} catch (Exception $e) { | |
echo $e->getMessage(); //Boring error messages from anything else! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment