هاست لینوکس

آخرین بسته‌ی MyBB: نسخه‌ی 1.8.27 MyBB منتشر شد


امتیاز موضوع:
  • 1 رأی - میانگین امتیازات: 5
  • 1
  • 2
  • 3
  • 4
  • 5
PHP - نمونه کد ارسال ایمیل
#1
کد php:
<?php
if(isset($_POST['btnSubmit']))
{
$txtBox1=$_POST['txtBox1'];
$txtBox2=$_POST['txtBox2'];
$HTML         "<table align=\"center\" cellspacing=\"0\" style=\"width: 350px; direction:rtl; font-family: tahoma; font-size: small; background-color: #FFF0F0;\" cellpadding=\"0\">
                <tr>
                <td style=\"width: 213px\"><br />
                &nbsp;&nbsp; textBox1:</td>
                <td><br /><b>
$txtBox1</b></td>
                </tr>                   
                <tr>   
                <td style=\"width: 213px\"><br />
                &nbsp;&nbsp; textBox2:</td>
                <td><br /><b>
$txtBox2</b></td>
                </tr>
                </table>"
;
        
$from         "info@abc.com";
        
$to           "ali@yahoo.com";
        
$subject     "Registration";
        
$headers "From: $from\r\n"
        
$headers .= "MIME-Version: 1.0\r\n"
        
$boundary uniqid("HTMLEMAIL"); 
        
$headers .= "Content-Type: multipart/alternative;".
                  
"boundary = $boundary\r\n\r\n"
        
$headers .= "This is a MIME encoded message.\r\n\r\n"
        
$headers .= "--$boundary\r\n".
                     
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
                     
"Content-Transfer-Encoding: base64\r\n\r\n"
        
$headers .= chunk_split(base64_encode(strip_tags($HTML))); 
        
$headers .= "--$boundary\r\n".
                    
"Content-Type: text/html; charset=ISO-8859-1\r\n".
                    
"Content-Transfer-Encoding: base64\r\n\r\n"
        
$headers .= chunk_split(base64_encode($HTML)); 
        
$success=mail($to,$subject,"",$headers);
        
//**************************************************************        
        
if (!$success
            {               
                 echo 
'<br><br><center>';
                 echo 
'<font face=Verdana size=2 color=red>خطا در ارسال ايميل</font>';
                 echo 
'</center>';
                echo (
"<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=$_SERVER[PHP_SELF]?link=users\">");
            }
        else
            {
                
$mq("$UP t_users SET mailstatus='1' WHERE id='$id'");
                echo 
'<script>';echo "alert('ايميل با موفقيت ارسال گرديد')"; echo '</script>';
                echo (
"<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$_SERVER[PHP_SELF]?link=users\">");
            }

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>text1</title>
</head>

<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    text1:<input name="txtBox1" type="text" /><br />
    text2:<input name="txtBox2" type="text" /><br />
    <input name="Submit1" type="submit" value="btnSubmit" /></form>
</body>

</html>



<?php
// multiple recipients
$to  'aidan@example.com' ', '// note the comma
$to .= 'wez@example.com';

// subject
$subject 'Birthday Reminders for August';

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

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

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

// Mail it
mail($to$subject$message$headers);
?>

//*******************************************************************************************  
//*******************************************************************************************  
//*******************************************************************************************  
<?php
$HTML         
'<b>Welcome dear user to my site</b>';
$from         "info@mysite.com";
$to           "XXXXXXXXXXX@yahoo.com";
$subject     "mysite.com Registration";
$headers "From: $from\r\n"
$headers .= "MIME-Version: 1.0\r\n"
$boundary uniqid("HTMLEMAIL"); 
$headers .= "Content-Type: multipart/alternative;".
          
"boundary = $boundary\r\n\r\n"
$headers .= "This is a MIME encoded message.\r\n\r\n"
$headers .= "--$boundary\r\n".
             
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
             
"Content-Transfer-Encoding: base64\r\n\r\n"
$headers .= chunk_split(base64_encode(strip_tags($HTML))); 
$headers .= "--$boundary\r\n".
            
"Content-Type: text/html; charset=ISO-8859-1\r\n".
            
"Content-Transfer-Encoding: base64\r\n\r\n"
$headers .= chunk_split(base64_encode($HTML)); 
$success=mail($to,$subject,"",$headers);
if (!
$success
{               
    echo 
'حطا';
}
else
{
    echo 
'ارسال گرديد';
}
?>
//************************************************************** 
پاسخ
 سپاس شده توسطms83 (۱۳۹۱/۱/۱۳، ۰۸:۳۶:۵۱ صبح) ، mhy (۱۳۹۱/۱/۱۳، ۰۸:۴۹:۵۵ صبح) ، Doodoo (۱۳۹۱/۱/۱۳، ۰۸:۵۸:۱۹ صبح) ، Night (۱۳۹۱/۱/۱۳، ۱۳:۱۴:۳۵ عصر) ، khp (۱۳۹۱/۱/۱۳، ۱۵:۵۱:۳۵ عصر) ، شماره مجازی (۱۴۰۱/۸/۲۶، ۰۱:۴۷:۲۸ صبح) ، گراف مسنجر (۱۴۰۱/۱۰/۳، ۰۴:۱۰:۰۰ صبح) ، چارتر ۴۲۴ (۱۴۰۲/۹/۱۲، ۱۵:۰۹:۰۸ عصر)


پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 1 مهمان