philna_sendmail.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. $options = get_option('philna_options');
  3. if($options['authorname']=='' || $options['authorname']==''):
  4. _e('<div class="mailinfo" style="color:red;"><p><strong>You should set your name and E_mail if you want to use the contact template page</strong></p></div>','philna');
  5. else:
  6. ?>
  7. <?php
  8. $options = get_option('philna_options');
  9. function yinheli_sendmail($to,$subject,$message){
  10. $blogname = get_option('blogname');
  11. $charset = get_option('blog_charset');
  12. $yinheli_sendmail_headers = "From: $blogname \n" ;
  13. $yinheli_sendmail_headers .= "MIME-Version: 1.0\n";
  14. $yinheli_sendmail_headers .= "Content-Type: text/html;charset=\"$charset\"\n";
  15. return @wp_mail($to, $subject, $message, $yinheli_sendmail_headers);
  16. }
  17. $m='';$s='';$msg='';
  18. if (isset($_POST["sendmail"])){
  19. if(!is_email($_POST["mailfrom"])){
  20. _e('<div class="mailinfo" style="color: #008800;"><p>Please enter a valid email address!</p></div>','philna');
  21. $s=$_POST["subject"];
  22. $msg=$_POST["message"];
  23. }elseif($_POST["subject"]==''){
  24. _e('<div class="mailinfo" style="color: #008800;"><p>Please enter the e-mail Subject</p></div>','philna');
  25. $s=$_POST["subject"];
  26. $msg=$_POST["message"];
  27. }elseif($_SESSION['VCODE']!==$_POST["yzm"]){
  28. _e('<div class="mailinfo" style="color: #008800;"><p>Verification Code error</p></div>','philna');
  29. $m=$_POST["mailfrom"];
  30. $s=$_POST["subject"];
  31. $msg=$_POST["message"];
  32. }elseif($_POST["message"]==''){
  33. _e('<div class="mailinfo" style="color: #008800;"><p>please type the content</p></div>','philna');
  34. $s=$_POST["subject"];
  35. }else{
  36. //格式化输出
  37. $tome=$options['authormail'];
  38. $authorname=$options['authorname'];
  39. $tocc=$_POST["mailfrom"];
  40. $tome_subject=$_POST["subject"].'---from-'.$_POST["mailfrom"];
  41. $tocc_subject='CC: '.$_POST["subject"].'-----You sended a mail to '.$authorname;
  42. $tome_message='Someone sended me a mail,his(her) E_mail is :'.$_POST["mailfrom"].' The following are the contents of<hr>'.$_POST["message"];
  43. $tocc_message='Thank you directly send a mail through my blog.I will reply as soon as possible The following are the contents of<hr>'.$_POST["message"];
  44. //发送邮件
  45. yinheli_sendmail($tome,$tome_subject,$tome_message);
  46. yinheli_sendmail($tocc,$tocc_subject,$tocc_message);
  47. _e('<div class="mailinfo"><p><strong>Your message has been sent</strong></p></div>','philna');
  48. }
  49. }else{
  50. _e('<p><strong>Give me a direct email</strong></p>','philna');
  51. }
  52. ?>
  53. <div id="mailform" >
  54. <form method="post" action="" >
  55. <div class="row"><input id="mailfrom" class="sendtext" name="mailfrom" type="text" value="<?echo $m;?>" tabindex="1" />
  56. <label for="mailfrom" class="small"><?php _e('E-Mail (required)', 'philna');?></label></div>
  57. <div class="row"><input id="subject" class="sendtext" name="subject" type="text" value="<?echo $s?>" tabindex="2" />
  58. <label for="subject" class="small"><?php _e('E-mail Subject (required)', 'philna');?></label></div>
  59. <div class="row"><input id="yzm" class="sendtext" name="yzm" type="text" value="" tabindex="3" />
  60. <label for="yzm" class="small"><?php _e('Verification Code', 'philna');?>(*):<img class="yzimg" src="<?php bloginfo('template_url'); ?>/yz_img.php" alt="Click the picture to refresh" onclick="this.src=this.src+'?'" style="cursor:pointer;" /><small style="color:#ABABAB;">Click the picture to refresh</small></label></div>
  61. <div class="row"><textarea id="sendmsg" class="sendmsg" style="width:630px;" name="message" cols="50" rows="8" tabindex="4"><?echo $msg?></textarea></div>
  62. <p class="alignright"><input class="sendsub" type="submit" name="sendmail" value="<?php _e('Send e-mail','philna')?>" tabindex="5"/></p>
  63. <p>E-mail form author:<a href="http://philna.com">yinheli</a></p>
  64. </form>
  65. </div>
  66. <?php endif;?>