0

我面临一个问题,我从我的 php 表单发送邮件显示该邮件已发送,但它没有反映在我的个人邮件中。我一直在寻找解决方案找到简单的电子邮件表格,即使我无法获得确切的解决方案。如果有人知道解决方案,请分享和帮助。

<?php
function spamcheck($field)
  {
    $field=filter_var($field, FILTER_SANITIZE_EMAIL);
    if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

if (isset($_REQUEST['email']))
  {
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";
    }
  else
    {
    $email = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;
    mail("someone@gmail.com", "Subject: $subject",
    $message, "From: $email" );
    echo "Thank you for using our mail form";
    }
  }
else
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text'><br>
  Subject: <input name='subject' type='text'><br>
  Message:<br>
  <textarea name='message' rows='15' cols='40'>
  </textarea><br>
  <input type='submit'>
  </form>";
  }
?>
4

1 回答 1

0

要拥有更好的结构(PHP 5 对象),请尝试使用 SwiftMailer:http ://swiftmailer.org/

        require_once('swiftBundle/lib/swift_required.php');

        $body='your HTML';

        // SMTP
        $transport = Swift_MailTransport::newInstance();

        $mailer = Swift_Mailer::newInstance($transport);

        $message = Swift_Message::newInstance()
        ->setSubject('Subject Mail')
        ->setFrom(array('mail' => 'name'))
        ->setTo(array('mail' => 'name'))
        ->setBody($body);

        $type = $message->getHeaders()->get('Content-Type');
        $type->setValue('text/html');
        $type->setParameter('charset', 'utf-8');

        $result = $mailer->send($message);
于 2013-09-27T07:44:24.507 回答