Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
persian simple send mail with php
<!DOCTYPE html>
<title>Email Form</title>
<style type="text/css">
.email-form {
font-size: 12px;
font-family: tahoma;
margin: 50px auto;
width: 500px;
height: auto;
background-color: #eee;
padding: 20px;
direction: rtl;
text-align: right;
.email-form * {
font-size: 12px;
font-family: tahoma;
.email-form h2 {
padding-bottom: 20px;
border-bottom: 1px dotted #000;
.email-form input[type="text"], .email-form textarea {
width: 100%;
box-sizing: border-box;
padding: 5px;
outline: none;
resize: none;
.email-form input[type="submit"] {
padding: 10px 20px;
float: left;
cursor: pointer;
.email-form .clear {
clear: both;
$error = -1;
if( isset($_POST['title']) && isset($_POST['to']) && isset($_POST['mail_content']) )
if( !empty($_POST['title']) && !empty($_POST['to']) && !empty($_POST['mail_content']) )
$title = ltrim(rtrim($_POST['title']));
$to = ltrim(rtrim($_POST['to']));
$mail_content = ltrim(rtrim($_POST['mail_content']));
if(!mail($to, $title, $mail_content))
$error = 'ارسال با مشکل روبرو شده است.';
$error = 'ارسال با موفقیت انجام شد.';
$error = 'تمامی فیلدها را پر کنید.';
<form action="" method="post" class="email-form">
<h2>ارسال ایمیل</h2>
<p><label for="title">موضوع :</label></p>
<p><input type="text" name="title" id="title" /></p>
<p><label for="to">گیرنده :</label></p>
<p><input type="text" name="to" id="to" /></p>
<p><label for="mail_content">متن ایمیل :</label></p>
<p><textarea id="mail_content" name="mail_content" rows="7"></textarea></p>
<p><input type="submit" value="ارسال" /></p>
<div class="clear"></div>
<p class="error"><?php if($error !== -1) echo $error; ?></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.