php - HTML 感谢邮件未发送

标签 php html email

我正在尝试设置一个基本的电子邮件,以便在用户提交表单时发送(他们输入详细信息,包括电子邮件地址,然后向该电子邮件地址发送一封感谢电子邮件)。我在一个页面上工作,但是,当试图在另一个页面上实现它时,我似乎无法获得他们输入的用户电子邮件地址。我习惯了非常基本的 PHP,我似乎无法让它工作的页面比我习惯的要复杂得多。

在我看来,我应该告诉电子邮件要发送到 $uEmail,但是当我这样做时,没有电子邮件被发送。这个确切的代码适用于另一个更基本的 PHP 页面,但我需要让它正常工作的页面是由比我更有经验的人创建的。

如果能在这件事上提供帮助,我将不胜感激。

  <form method="post" action="<?php echo $this->url('/clients/register', 'do_register')?>" class="clearfix">

        <?php  if ($displayUserName) { ?>
            <div>
            <?php echo $form->label('uName', t('Username') )?>
            <?php echo $form->text('uName')?>
            </div>
            <br/>
        <?php  } ?>

        <div>
          <div>
            <?php echo $form->label('uEmail', t('Email Address') )?>
            <span class="ccm-required">*</span>
          </div>
          <?php echo $form->text('uEmail')?>
        </div>
        <br/>

        <?php

        $attribs = UserAttributeKey::getRegistrationList();

        //UserAttributeKey::getRegistrationList();

        $af = Loader::helper('form/attribute');

        foreach($attribs as $ak) {
 //                $ak = UserAttributeKey::getByHandle($akHandle);
            print $af->display($ak, $ak->isAttributeKeyRequiredOnRegister());
 //                print '<br/><br/>';
        }

        if (ENABLE_REGISTRATION_CAPTCHA) {
            print $form->label('captcha', t('Please type the letters and numbers shown in the image.'));
            //print '<br/>';
            $captcha = Loader::helper('validation/captcha');
            $captcha->display();
            ?>

            <div><?php  $captcha->showInput();?> </div>
        <?php  } ?>

        <br/>

       <!-- checkbox code -->

      <!-- end checkbox code -->

     <input type="hidden" name="sendCopy" id="sendCopy" value="true"<?php if(isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) echo ' checked="checked"'; ?> />

        <div class="ccm-button">
            <?php echo $form->submit('register', t('Register'))?>
            <?php echo $form->hidden('rcID', $rcID); ?>
        </div>

    </form>
    <?php  } ?>

   <?php 
   if (mysql_affected_rows()) {

   // NEW TEMP CODE
   //if (isset($error) && $error != '') { 
   //if (isset($_POST['register'])) {

    $emailTo = 'allen.hughes@hotmail.com';
    $subject='Application form submission from test.com';
    $sendCopy = trim($_POST['sendCopy']);
    $body = "Email: Hello! Thanks for applying...test***";
        $headers = 'From: Allen hughes ' . 'Reply-To: ' . $email;

    mail($uEmail, $emailTo, $subject, $body);

    if($sendCopy == true) {
        $subject = 'You applied to Allenhughes.com';
    mail($uEmail, $subject, $body);
    }
    $emailSent = true; 
   }
   else { 

  echo "Confirmation email has not been sent as email address has not been specified";

   }

   ?>

最佳答案

90% 的情况下,此错误是由服务器的某些配置错误引起的。

检查您的电子邮件日志是否有任何错误

同时检查邮件函数返回什么

if (mail()) {
  echo 'succesful';
}

关于php - HTML 感谢邮件未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12916945/

相关文章:

javascript - onclick按钮展开为表单

windows - 将传入电子邮件通过管道传输到 Windows IIS SMTP 上的脚本?

php - 在电子邮件消息 php 中输出 <hr>

php - 使用 XHProf 运行 drupal 页面后运行 ID 无效

php - 发送 POST 数据时是否可以重定向?

php - 如果电子邮件为空,则名称为电子邮件链接,否则名称

jquery - 如何根据内容选择元素?

php - 如何将数据传递到高级 REST 客户端 Chrome 扩展

html - rails : Render HTML directly from controller.

email - 使用 AWS EC2 和 SES 时如何创建电子邮件帐户并设置电子邮件接收器?