Sign In!
|
New User?Signup Now!
|
Forgot password?
Source Code 4 you
Home
Create Forum Topic
Check WebSite Rank
Publish Articles
UV Web Booster
Contact
Forum Type
Search Engine
.Net C# VB F# VC++
MonoPoject
Java J2EE
Zand Php Cake Php
Oracle Database Server
Mysql Database Server
DB2 Database Server
MSSql Databse Server
Javascript Ajax
Html Xml Xhtml
C Programming
C++ Programming
D Programming
CGI Programming
Perl Programming
Cobol Programming
Pascal Programming
Ruby Programming
Drupal Programming
Automobile
Software Testing
Linux Unix Mac Sun OS
Embedded Systems
Mainframe
IC Microcircuit Chip
Electronics Electrical
Hardware Netwarking
SAP ERP
Logical Reasoning
Human Resources
Science
Agriculture
Accounting
History
Pharmaceutical
Other Topic
Zand Php Cake Php
Posted by :
Pavan PHP
Sending Simple HTML Email Message based on SMTP via PHP Script
Can any one share me the source code to send html email message using
smtp authentication (smtp server username and password) via php
script. It should also allow cc, bcc, reply-to email, host etc.
As of now I am using mail() which is very much limited and does not
provide the features I am looking for.
Regards
Pavan
Posted by :
Christopher Robinson
Re : Sending Simple HTML Email Message based on SMTP via PHP Script
It's pretty simple I think. I just gave you the chapter on Zend_Mail.
SMTP auth is in there. Here's a really simple class I use to send
notifications:
require_once 'Zend/Mail.php';
require_once 'Zend/Mail/Transport/Smtp.php'
;
class notify
{
//Email account to use
private $username = "automated";
private $password = "******";
private $email_server = "
mail.example.com
";
private $from =
"me@example.com"
;
private $from_name = "Automated Email";
public function __construct()
{
$config = array('auth' => 'login',
'username' => $this->username,
'password' => $this->password);
$tr = new
Zend_Mail_Transport_Smtp($
this->email_server,$config);
Zend_Mail::
setDefaultTransport($tr);
}
public function sendNotice($to,$subject,$body,
$to_name="Automated
Recipiant")
{
$mail = new Zend_Mail();
$text = strip_tags($body);
$mail->setBodyText($text);
$mail->setBodyHtml($body);
$mail->setFrom($this->from, $this->from_name);
$mail->addTo($to,$to_name);
$mail->setSubject($subject);
$mail->send();
unset($mail);
}
}
/* Usage example
$mytest = new notify();
$mytest->sendNotice(
"
crobinson@example.com"
,"Hello,
just a test of
the EBS","Ok, so this is the test<br>Not much I know.");
*/
If you have the better reply, then send it to us. We will display your reply after the approval.
Name :
Email Id :
Reply :