|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/test_send_mail/ |
Upload File : |
<?
function mail_daily_request($title_name,$email_to,$email_from,$msgtext,$refid=''){
global $PHP_SELF;
//require_once "Mail.php";
require("class.phpmailer.php");
//$msg= "MIME-Version: 1.0\r\n";
//$msg .= "Content-type: text/html; charset=tis-612\r\n";
$msg = "
<head>
<title> HTML content</title>
</head>
<body>".ereg_replace(chr(13),"<br>", $msgtext)."</body>
</html>
";
$from = $email_from;
$to = $email_to;
$subject = iconv('TIS-620', 'UTF-8',$title_name);
$msg = iconv('TIS-620', 'UTF-8',$msg);
//$subject = $title_name;
$body = $msg;
$host = "mail.sapphire.co.th";
$username = "system@sapphire.co.th";
$password = "sapphire";
$content=" text/html; charset=utf-8";
//$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject, 'Content-Type' => $content);
//$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
//$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
//$mail = $smtp->send($to, $headers, $body);
//if (PEAR::isError($mail)) {
//echo $mail->getMessage();
//}else {
//echo "Message successfully sent!";
//}
###################### NEW MAILLER 5.1
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->CharSet ="utf-8";
//$mail->IsSMTP();
$mail->Host ="mail.sapphire.co.th";
$mail->Port=25;
$mail->Username = $username; // SMTP username
$mail->Password = $password; // SMTP password
$mail->From = "$from";
$mail->FromName = "EPM SAPPHIRE R&D";
$mail->AddAddress("$to");
$mail->AddReplyTo("$from");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
//$mail->AddCC('pudis@sapphire.co.th', 'Third Person');
//$mail->AddCC('apiwat@sapphire.co.th', 'Third Person');
//$mail->AddCC('agasit@sapphire.co.th', 'Third Person');
$mail->Subject = "$subject";
$mail->Body = "$msg";
//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
//echo "$subject"."$msg";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
###################### END MAILLER 5.1
}