Salam,
Saya masih baru dalam program Php..minta bantuan macammane nak send email after submit form dari localhost ke domain yahoo/gmail/dll..saya dah berpuluh kali try dari tutorial tapi hasilnya...
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\sispemel\mailer.php on line 28
Thank you for submitting our form. We will get back to you as soon as possible.
Q1:Form dah sent..tapi kenapa keluar error macamtu.
saya dah setting kat php.ini seperti di bawah..
[mail function] ; For Win32 only. ;http://php.net/smtp ;SMTP = localhost ;http://php.net/smtp-port ;smtp_port = 25
; For Win32 only.
;http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
..................
..................
; Windows: "\path1;\path2"
include_path = ".;D:\xampp\phpmailer_5.2.0"
Q2:adakah betul cara saya setting macamni?
Q3:saya telah download file phpmailer 5.2.0 then save kat dir seperti di atas.adakah cara saya ini betul?
Q4:bila saya nak panggil file class phpmailer tu, saya code seperti berikut:-
<?PHP require("class.phpmailer.php");
$to = "*****@yahoo.com";
$subject = "Untuk pengesahan permohonan email";
$headers = "From: Form Mailer";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>
Harap sangat ade yang dapat membantu...saya dah betul2 buntu...TQ
saya dah try search tentang mercury..bukan ke yang tu setup untuk send mail from localhost to localhost user..hmm..kalau nak send mail from localhost to external mail like yahoo or gmail, any idea?sbb sy try google boleh guna function mail()..but the problem is function mail() saya tak jalan..n masalah yang timbul macam saya nyatakan kat atas..boleh share any tips..TQ
cuba tengok link ni bro - http://egrasp.wordpress.com/2010/02/03/sending-email-in-php-using-xampp-lite-1-7-3-on-windows/
salam saya nak tnya
saya nak sent excel file ke email,
masalahnya sent tersebut berjaya tetapi ia xbawak excel name yang appear kat email saya untitled.
so bagi user2 yang gune thunderbird or outlook akan terima data dlam bentuk .dat.
ni contoh coding nye
$boundary = uniqid( "");
$headers = "Content-type:multipart/mixed; boundary=\"$boundary\"";
$emailBody = "--$boundary
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: 8bit
$emailstart
--$boundary
Content-type: text/html; name=automaseindstockstatus.xls
Content-disposition:inline; filename=automaseindstockstatus.xls
Content-transfer-encoding: 8bit
$reportresult
--$boundary--";
//mail('yfleaw@masegroup.com,elwin@masegroup.com','(Auto)Product Status Report(Dairy)',$emailBody,$headers);
//=================================PEAR MAIL FUNCTION=====================================================
$sender = "postmaster@mase.com.my"; // Display Sender email address
$recipient = "emma@masegroup.com";
$subject = "(Auto)Product Status Report(Dairy)---[202]";
$crlf = "\n";
$headers = array(
'From' => $sender,
'To' => $recipient,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
//$mime->setTXTBody($text);
$mime->setHTMLBody($emailstart);
$file_name = "automaseindstockstatus.xls";
$reportresult="automaseindstockstatus.xls";
$content_type = "Application/xls";
$mime->addAttachment($reportresult, $content_type,"automaseindstockstatus.xls", 0);
// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);
// SMTP authentication params
$smtp_params["host"] = "mail.masegroup.com";
$smtp_params["port"] = "26";
$smtp_params["auth"] = true;
$smtp_params["username"] = "postmaster@masegroup.com";
$smtp_params["password"] = "mase883884";
// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
$result = $mail->send($recipient, $headers, $body);
if($result == 1)
{
echo("Your message has been sent!");
}
else
{
echo("Your message was not sent: " . $result);
}
harap2 sgt2 boleh tlg sya solvekan masalah ni
thanks
saya terima email attachement seperti ini untitled-[2].xls
nak hantar mail kena ada mail server from localhost
kalau guna xampp tu try on mercury. pastu google ler pasal mercury ni nak tahu lebih lanjut..