To protect essentials network, servers, and customers from spamming, it requires the use of SMTP-auth for all methods of sending email. The basic PHP Mail function does not support SMTP-auth, therefore cannot be used.
To write your own PHP code to send email using SMTP-auth, there are PHP PEAR Mail package available for usage (which supports smtp-auth). PHP code sample below shows how to use this feature to send an email:
require_once "Mail.php";
/**************************************************
EDIT the following variables for your own use
***************************************************/
$from = "user@domain";
$to = "user2@domain2";
$subject = "Hi!"; //type in subject here
$host = "host_ip"; // Your domain
$username = "user"; // Your user / full email address
$password = "password"; // Password to your email address
/**************************************************
***************************************************/
$body = "Test";
foreach($_POST as $a => $b)
{
$body .= $a .": ". $b . "\n";
}
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
/**************************************************
ERROR MESSAGE
***************************************************/
?>
getMessage(); ?>
/**************************************************/
} else {
/**************************************************
SUCCESS MESSAGE
***************************************************/
?>
Message successfully sent!
/**************************************************/
}
?>
grabbed from here
Filed under: PHP, PEAR::MAIL, PHP
[...] kerjaan ke mas Yudhi. hahaha.. dan dapet donk. Mas Yudhi emang buaekk. Kemarin kan udh berhasil ngoprek PEAR::MAIL, sekarang misinya dilanjutkan dengan meng-install SVN (subversion) di server ubuntu tercintanya, [...]
disitu kan ada require_once (“Mail.php”); tapi aku ga ngeliat ada file mail.php. Apakah mail.php itu bawaan dari phpnya atau gmana?