知道为什么我的邮件功能不起作用吗?

时间:2015-12-31 16:01:49

标签: php email

HTML代码:

from django import forms
from .models import Language
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class FreelancerRegistrationForm(forms.Form):
    language = forms.ModelChoiceField(queryset=Language.objects.all().order_by('shortcut'))

PHP代码:

<form method="post" action="form.php">
    <div class="col-sm-6 form-group">
    <input class="form-control" id="name" name="name" type="text" placeholder="Name">
  </div>
  <div class="col-sm-6 form-group">
  <input class="form-control" id="email" name="email" type="email" placeholder="Email">
  </div>
  <div class="col-xs-12">
  <textarea class="form-control" id="message" name="message" type="message" rows="5" placeholder="Message"></textarea>
  </div>
  <button type="button" id="submit">Submit</button>
  <?php echo $result; ?>  
</form>

所以这是代码,我不知道为什么在提交表单时仍然没有收到邮件。我尝试了我所知道的一切,但它仍然是一样的。此外,我正在使用支持发送电子邮件和PHP等的网络托管。它仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

那里有多个逻辑和句法问题。

  1. 在将其分配给任何变量之前,您需要验证$ _POST。
  2. 您正在使用$ subject但该变量中没有任何值。
  3. 您正在将标题值混合到邮件正文
  4. 我试图修复问题试试这个。

    WITH Members AS
    (
        --note, for a CTE, all columns in the select must have a name (or you must specify the column names above next to the CTE name)
        SELECT TOP 8 PERCENT mem.id, entrantId, ... FROM recMembers [mem] ... ORDER BY ...
    ),
    Judges AS
    (
        SELECT Id [judgeId] FROM recMembers WHERE Privilege >= 2
    )
    INSERT INTO recEntrantStatus (entrantId, roundId, judgeId, notified, voted, enterNextRound)
    SELECT m.entrantId, ...
    FROM Members m, Judges j --cross join of your top 8% members and all of your judges
    WHERE ...
    

    有关详细信息,请参阅此http://php.net/manual/en/function.mail.php