$ sudo aptitude install php-pear php-mailAfter installation use following codes to send email:
<?php require_once "Mail.php"; $recipients = "to@example.com"; $headers["From"] = "from@example.com"; $headers["To"] = "to@example.com"; $headers["Subject"] = "Test message"; $mailmsg = "Hello, this is a test message"; /* SMTP server name, port, user/passwd */ $smtpinfo["host"] = "smtp.example.com"; $smtpinfo["port"] = "25"; $smtpinfo["auth"] = true; $smtpinfo["username"] = "username"; $smtpinfo["password"] = "password"; /* Create the mail object using the Mail::factory method */ $smtp = Mail::factory("smtp", $smtpinfo); $mail = $smtp->send($recipients, $headers, $mailmsg); ?>Notes: replace "example" with the real domains, and put in your username and password. If you get an error message like this: Fatal error: Cannot instantiate non-existent class: net_smtp in
/usr/share/php/Mail/smtp.php on line 159, please install Net_SMTP package by:
$ sudo pear install Net_SMTP
No comments:
Post a Comment