PDA

View Full Version : سوال php : فرم ارسال ايميل


payamix
21 September 2004, 10:19 PM
من اينو درست كردم اما كار نميكنه :|
لطفن اگه ايرادش رو گرفتين توضيح هم بدين تا ياد بگيرم ٬ مرسي :wink:

<?
$email_address = "webmaster@xxx.com";
$email_name = "Visitor Contact";

$body = "";
$body .= "Name: " . $name . "\n";
$body .= "email: " . $email . "\n";
$body .= "Message:\n " . ereg_replace("\n", "\n ", $message) . "\n";

$headers = "";
$headers .= "From: " . $email_name . " <" . $email_address . ">\n";
$headers .= "X-Sender: <" . $email_address . ">\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "X-Priority: 1\n";
$headers .= "Return-Path: <" . $email_address . ">\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";

@mail($email_address, "EOF", "<pre>" . $body . "</pre>", $headers);

if (mail($email_address, "EOF", "<pre>" . $body . "</pre>", $headers)) {
print("Your Comment was sent to the Webmaster Successfully.");
} else {
print ("Something went wrong with the script! Please try again.");
?>

payamix
21 September 2004, 10:21 PM
يه راهنمايي هم بكنم : اون چند خط شرطي آخر رو بردارم درست ميشه٬ هر چي هست زير سر او if هستش :|

Shahram_gle
21 September 2004, 10:34 PM
بعد از else كه يه پرانتز قرار دادي. فكر كنم چون پرانتز انتهاي دستور رو نزاشتين اشكال داره يعني اينجوري بايد بنويسي.
if (mail($email_address, "EOF", "<pre>" . $body . "</pre>", $headers)) {
print("Your Comment was sent to the Webmaster Successfully.");
} else {
print ("Something went wrong with the script! Please try again."); {

payamix
21 September 2004, 11:34 PM
مرسي
آدم وقتي هفت هشت ساعت يك ريز بشينه جلوي مونيتور همين بلا سرش مياد ! :arrow:

Shahram_gle
22 September 2004, 01:02 AM
خواهش ميكنم. وظيفه بود.
اين فروم براي همين كارا ساخته شده ديگه. 8)

Kam-Telecom
22 September 2004, 01:22 AM
حالا صحيحش رو ميشه دوباره بصورت كد بزارين.

houtanal
22 September 2004, 01:26 AM
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

&lt;?php
mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");
?>


&lt;?php
/* recipients */
$to = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message = '
&lt;html>
&lt;head>
&lt;title>Birthday Reminders for August&lt;/title>
&lt;/head>
&lt;body>
&lt;p>Here are the birthdays upcoming in August!&lt;/p>
&lt;table>
&lt;tr>
&lt;th>Person&lt;/th>&lt;th>Day&lt;/th>&lt;th>Month&lt;/th>&lt;th>Year&lt;/th>
&lt;/tr>
&lt;tr>
&lt;td>Joe&lt;/td>&lt;td>3rd&lt;/td>&lt;td>August&lt;/td>&lt;td>1970&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Sally&lt;/td>&lt;td>17th&lt;/td>&lt;td>August&lt;/td>&lt;td>1973&lt;/td>
&lt;/tr>
&lt;/table>
&lt;/body>
&lt;/html>
';

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: Mary &lt;mary@example.com>, Kelly &lt;kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder &lt;birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);
?>

Shahram_gle
22 September 2004, 01:27 AM
كد همونه
فقط به آخر دستور print("something went wrong يه پرانتز اضافه كن.