PDA

View Full Version : ارسال ایمیل



saeed-71
سه شنبه 06 خرداد 1393, 00:33 صبح
سلام.
ارسال ایمیل با قالب اختصاصی در پی اچ پی چجوریه؟

rezakho
سه شنبه 06 خرداد 1393, 11:31 صبح
http://css-tricks.com/sending-nice-html-email-with-php/

saeed-71
سه شنبه 06 خرداد 1393, 12:04 عصر
مشکل این کد چیه که ایمیل ارسال نمیکنه؟





<?php
if(isset($_POST['frm_submit']))
{

$name=htmlspecialchars($_POST['name']);
$email=htmlspecialchars($_POST['email']);
$subject=htmlspecialchars($_POST['subject']);
$content=htmlspecialchars($_POST['content']);
if(sendEmail($name,$email,$subject,$content)){
echo "Email Has Been Sent Successfully.";
}
else
{
echo "Send Email Was Failure.";
}
}
function sendEmail($name,$email,$subject,$content){
ob_start();
include 'template.php';
$html=ob_get_contents();
ob_end_clean();
$html= str_replace('{name}',$name, $html);
$html= str_replace('{email}',$email, $html);
$html= str_replace('{subject}',$subject, $html);
$html= str_replace('{content}',$content,$html);
$headers = 'From: no-reply@domain.com'. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

return mail("131321@gmail.com","درخواست جدید در وب سایت", $html, $headers);
}
?>

<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background-color: #EEE;width:100%;height:100%">
<div style="font-family: tahoma;font-size: 100%;direction: rtl;border:1px solid #CCC;width:500px; margin:50px auto;background-color: #FFF;border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;">
<div style="width:100%;border-bottom: 2px solid #CCC;text-align: center;font-size: 10pt;padding: 20px 0;background-color:#DDD;">درخواست جدید از وب سایت شما</div>
<div style="font-size: 9pt;padding: 20px;line-height: 150%;">
<h4 style=" text-align: right;margin-bottom: 20px;color:#009;">مدیر محترم وب سایت ،درخواست جدیدی از وب سایت ارسال شده است</h4>
<p><span>نام ارسال کننده : </span>{name}</p>
<p><span>ایمیل ارسال کننده :</span> {email}</p>
<p><span>موضوع :</span> {subject}</p>
<p><span>متن ارسالی :</span>{content}</p>
</div>
</div>
</body>

</html>

MRmoon
سه شنبه 06 خرداد 1393, 15:43 عصر
مشکل این کد چیه که ایمیل ارسال نمیکنه؟





<?php
if(isset($_POST['frm_submit']))
{

$name=htmlspecialchars($_POST['name']);
$email=htmlspecialchars($_POST['email']);
$subject=htmlspecialchars($_POST['subject']);
$content=htmlspecialchars($_POST['content']);
if(sendEmail($name,$email,$subject,$content)){
echo "Email Has Been Sent Successfully.";
}
else
{
echo "Send Email Was Failure.";
}
}
function sendEmail($name,$email,$subject,$content){
ob_start();
include 'template.php';
$html=ob_get_contents();
ob_end_clean();
$html= str_replace('{name}',$name, $html);
$html= str_replace('{email}',$email, $html);
$html= str_replace('{subject}',$subject, $html);
$html= str_replace('{content}',$content,$html);
$headers = 'From: no-reply@domain.com'. "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

return mail("131321@gmail.com","درخواست جدید در وب سایت", $html, $headers);
}
?>

<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background-color: #EEE;width:100%;height:100%">
<div style="font-family: tahoma;font-size: 100%;direction: rtl;border:1px solid #CCC;width:500px; margin:50px auto;background-color: #FFF;border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;">
<div style="width:100%;border-bottom: 2px solid #CCC;text-align: center;font-size: 10pt;padding: 20px 0;background-color:#DDD;">درخواست جدید از وب سایت شما</div>
<div style="font-size: 9pt;padding: 20px;line-height: 150%;">
<h4 style=" text-align: right;margin-bottom: 20px;color:#009;">مدیر محترم وب سایت ،درخواست جدیدی از وب سایت ارسال شده است</h4>
<p><span>نام ارسال کننده : </span>{name}</p>
<p><span>ایمیل ارسال کننده :</span> {email}</p>
<p><span>موضوع :</span> {subject}</p>
<p><span>متن ارسالی :</span>{content}</p>
</div>
</div>
</body>

</html>

میشه سوال کنم تو هاست دارین امتحان می کنید یا رو لوکال؟؟؟ چون برای ارسال ایمیل در لوکال باید یه چیزی رو نصب یا تنظیم کنی.

saeed-71
سه شنبه 06 خرداد 1393, 15:56 عصر
رو هاست امتحان کردم.اما برا لوکال باید چیو نصب یا تغییر بدم؟