你需要的只是發送郵件聯繫表格....
如果是這樣,考慮借力山魈服務是免費的,每月高達12,000電子郵件。
表格樣本(阿爾特滿足您的需求)
<h1>Contact</h1>
<br />
<div id="ContactMessageSentAlert" class="alert alert-success">
You're message has been sent.
</div>
<form role="form" id="ContactMessageForm">
<div class="form-group">
<label for="FirstName" class="sr-only legacy-label">First Name</label>
<input type="text" id="FirstName" name="FirstName" maxlength="255" class="form-control" placeholder="First Name" />
</div>
<div class="form-group">
<label for="LastName" class="sr-only legacy-label">Last Name</label>
<input type="text" id="LastName" name="LastName" maxlength="255" class="form-control" placeholder="Last Name" />
</div>
<div class="form-group">
<label for="EmailAddress" class="sr-only legacy-label">Email Address</label>
<input type="email" id="EmailAddress" name="EmailAddress" maxlength="255" class="form-control" placeholder="Email Address" />
</div>
<div class="form-group">
<label for="TwitterUsername" class="sr-only legacy-label">Twitter Username</label>
<input type="text" id="TwitterUsername" name="TwitterUsername" maxlength="16" class="form-control" placeholder="Twitter Username" />
</div>
<div class="form-group">
<label for="Subject" class="sr-only legacy-label">Subject</label>
<input type="text" id="Subject" name="Subject" maxlength="255" class="form-control" placeholder="Subject" />
</div>
<div class="form-group">
<label for="Message" class="sr-only legacy-label">Message</label>
<textarea id="Message" name="Message" rows="5" class="form-control" placeholder="Message"></textarea>
</div>
<button type="button" class="btn btn-default" id="ContactMessageSendButton">Send</button>
</form>
<script type="text/javascript" src="/scripts/mail.js" defer="defer"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#ContactMessageSentAlert').hide();
$('#ContactMessageForm').show();
$.validator.addMethod('twitterUsername', function(value, element) {
return this.optional(element) || /^(@?[a-zA-Z0-9\_]{1,15})$/.test(value);
}, 'Invalid');
var validator = $('#ContactMessageForm').validate({
errorElement: 'div',
rules: {
FirstName: {required: true},
LastName: {required: true},
EmailAddress: {required: true, email: true},
TwitterUsername: {twitterUsername: true},
Subject: {required: true},
Message: {required: true}
},
messages: {
FirstName: {required: 'Please enter your first name.'},
LastName: {required: 'Please enter your last name.'},
EmailAddress: {required: 'Please enter your email address.', email: 'Please enter a valid email address.'},
TwitterUsername: {twitterUsername: 'Please enter a valid Twitter username.'},
Subject: {required: 'Please enter a subject.'},
Message: {required: 'Please enter a message.'}
},
errorPlacement: function (error, element) {
$(error).insertBefore($(element));
},
highlight: function(element, errorClass) {
$(element).parent('div').addClass('has-error');
},
unhighlight: function(element, errorClass, validClass) {
$(element).parent('div').removeClass('has-error');
},
onfocusout: false,
invalidHandler: function(event, validator){
setTimeout(function(){
$('input:text').blur();
$('textarea').blur();
// Pseudo of input:email is not recognized by jQuery yet, so have to target the email fields individually.
$('#EmailAddress').blur();
}, 10);
}
});
});
</script>
/scripts/mail.js文件:
function sendMail(sender, senderName, recipient, subject, message) {
$.ajax({
type: 'POST',
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
data: {
/* Confirm API key before use! */
'key': 'YOURAPICODE',
'message': {
'from_email': '[email protected]',
'from_name': senderName,
"headers": {"Reply-To": sender},
'to': [{'email': recipient, 'type': 'to'}],
'autotext': 'true',
'subject': subject,
'html': message
}
}
})
};
/* Assign an OnClick function to items in the "Send" button */
$('#ContactMessageSendButton').click(function(e) {
$(document).ready(function() {
var form = $('#ContactMessageForm');
form.validate();
if (form.valid() === true) {
var sender = $.trim($('#EmailAddress').val());
var senderName = $.trim($('#FirstName').val()) + ' ' + $.trim($('#LastName').val());
var recipient = '[email protected]';
var subject = $.trim($('#Subject').val());
var message = $.trim($('#Message').val()).replace(/\n/g, '<br />') + '<br />' + $.trim($('#TwitterUsername').val());
sendMail(sender, senderName, recipient, subject, message);
$('#ContactMessageSentAlert').show();
$('#ContactMessageForm').hide();
}
});
});
Google for'PHP contact form'。你會得到大量的工作腳本。你可以很容易地從他們那裏學習 – wishchaser
我做過了,希望能有更多的基礎教程。我使用FormSpree,但我仍然希望學習一點PHP,並親自看看自己做了一個。謝謝! – Kevan
那麼,先學習PHP吧。那裏有很多基本的教程。我發現'w3schools'很好的學習基礎知識。這是人們發佈問題以尋找特定問題的答案的地方。不要學習一種全新的編程語言。快樂學習! – wishchaser