-1
我有一個關於從表單發送電子郵件的問題。在我的代碼中,當我點擊發送時(在代碼中顯示爲pošlji),它打開Outlook或在手機上打開Gmail。我想要的是它只會說發送和電子郵件將自動發送。這裏是代碼:自動從表單發送電子郵件
<div class="content">
<form action="mailto:[email protected]" enctype="text/plain" method="post">
<div class="row half no-collapse-1">
<div class="6u">
<input type="text" name="name" placeholder="Ime" />
</div>
<div class="6u">
<input type="text" name="email" placeholder="E-pošta" />
</div>
</div>
<div class="row half">
<div class="12u">
<textarea name="message" placeholder="Sporočilo" rows="7"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<ul class="buttons">
<li><input type="submit" name="submit" value="pošlji" class="button special"></li>
</ul>
</div>
</div>
</form>
</div>
</section>
而且我也有php文件,但它以某種方式它不起作用。下面的代碼:
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_comment = $_POST['cf_message'];
$mail_to = '[email protected]';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_comment;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact_page.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to [email protected]');
window.location = 'contact.html';
</script>
<?php
}
?>
哦,這裏的CSS此電子郵件的形式:
.to input[type="text"] {
padding: 10px 9px;
width: 48%;
font-size: 0.85em;
font-family: 'Exo 2', sans-serif;
margin: 10px 0;
border: 1px solid #EEE;
color: #777;
background: #FFF;
float: left;
outline: none;
}
.text input[type="text"], .text textarea {
width: 98.3%;
font-size:0.85em;
margin: 10px 0;
border: 1px solid #EEE;
color:#777;
font-family: 'Exo 2', sans-serif;
outline: none;
margin-bottom: 25px;
height: 150px;
padding:10px 9px;
}
.submit input[type="submit"] {
padding:10px 30px;
color: #FFF;
cursor: pointer;
background:#4CB1CA;
border:none;
outline:none;
font-family: 'Exo 2', sans-serif;
font-size:1em;
}
.submit input[type="submit"]:hover{
background:#555;
}
而這一切。
只是別的此代碼是在斯洛文尼亞語和名= Ime,電子郵件= E-pošta和消息=Sporočilo:)任何幫助將非常感激,謝謝。
'
好的,謝謝@tash我會試試 –
@jaka_music做到了嗎?如果是這樣,你應該接受答案 –