- Download PHPMailer Package from: http://sourceforge.net/project/showfiles.php?group_id=26031
- Unzip=install
- In the class “class.smtp.php”, there is a send method that can be used to send emails
- PHPMailer provides different ways of mailing: default php mail function [capabilities limited], Using a SMTP server [with or without authentication], using Sendmail software
- PHP mailer can attach files, can send HTML emails
- In the class “class.smtp.php”, you can write a function that can use send method to send emails. Your method can take parameters to set mailing parameters. Callers will supply the parameters.
- A sample method can be as follows:
public function prepareAndSendMail($fields){ date_default_timezone_set('America/Toronto'); $this->IsSMTP(); $this->IsHTML(true); // send as HTML $this->SMTPAuth = true; // enable SMTP authentication $this->SMTPSecure = "ssl"; // sets the prefix to the servier $this->Host = "SMTP server address"; // set SMTP server $this->Port = port usually 25 or 465;// set the SMTP port $this->Username = "user name for smtp server"; // smtp server username $this->Password = "user password"; // smtp server password $this->AddReplyTo("reply to email address",""); $this->From = "email address to send from"; $this->FromName = "sender's name"; $this->Subject = "subject of the email"; //$this->Body = "Hi, This is the HTML BODY
"; $this->AltBody = $fields["altBody"]; //non-html body $this->WordWrap = 50; // set word wrap $this->MsgHTML($fields["body"]); $this->AddAddress($fields["to"]); $this->AddAttachment($fields["attachment"]); // attachment if(!$this->Send()) { echo "Mailer Error: " . $this->ErrorInfo; } else { echo "Message sent!"; } }
From: http://sitestree.com/?p=5128
Categories:16
Tags:
Post Data:2010-12-19 23:49:23
Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a>
In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
<a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>