Wanna send some mail? |
You may download PHPMailer Library in this link: http://sourceforge.net/projects/phpmailer/
<?php require("class.phpmailer.php"); $mailer = new PHPMailer(); $mailer->IsSMTP(); $mailer->Host = 'ssl://smtp.gmail.com'; $mailer->Port = 465; //can be 587 $mailer->SMTPAuth = TRUE; // Change this to your gmail address $mailer->Username = 'yourusername@gmail.com'; // Change this to your gmail password $mailer->Password = 'yourpassword'; // Change this to your gmail address $mailer->From = 'yourusername@gmail.com'; // This will reflect as from name in the email to be sent $mailer->FromName = 'Your Name'; $mailer->Body = 'This is the body of your email.'; $mailer->Subject = 'This is your subject.'; // This is where you want your email to be sent $mailer->AddAddress('samplemail@yahoo.com'); if(!$mailer->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mailer->ErrorInfo; } else { echo "Message has been sent"; } ?>
If you want to add some attachments, just add a line something like this:
For instant testing, you may download this code with the library files used and change the variables to your settings:
You can find more examples here.
$mailer->AddAttachment('yourfolder/yourfile.gif');
For instant testing, you may download this code with the library files used and change the variables to your settings:
You can find more examples here.
For FREE programming tutorials, click the red button below and subscribe! :)
website