如何在被称为wordpress页面的联系页面(corephp)中使用代码点火器电子邮件


how to use code igniter email in a contact page (core php) called as a wordpress page?

如何在被称为wordpress页面的联系页面(core php)中使用代码点火器电子邮件。我可以让它无文字压力&独立的php文件(如果需要的话)。核心php邮件的问题是它会将所有邮件直接发送到垃圾邮件文件夹中。

if(!$error)

 {
    //trim($_POST[your_name])." sent you a message from ".get_option("blogname")." website "." on subject "

    $headers = "From: ".trim($_POST[your_name])." <".trim($_POST[your_email]).">'r'nReply-To:".trim($_POST[your_email])."'r'n" ;
    $headers .=  'MIME-Version: 1.0' . "'r'n";
    $headers .=  'mailed-by: hisham@rainhopes.com' . "'r'n";
    $headers .= "X-Priority: 2'nX-MSmail-Priority: high";
  //$headers .= 'From: abc@yahoo.com' . "'r'n";

     $email = mail(get_option("admin_email"),trim($_POST[your_subject]),stripslashes(trim($_POST[your_message])),$headers);
}

  } 

mail()函数不会为使用流行功能(如基于HTML的电子邮件和邮箱附件)提供任何帮助。

我建议使用PHPMailer库,这是最健壮、最实用的php邮件库。

编辑此代码应完成的工作

if(!$error){
    require 'path/to/PHPMailerAutoload.php';
    $mail = new PHPMailer;
    $mail->setFrom(trim($_POST[your_name]));   
    $mail->addReplyTo(trim($_POST[your_email]));
    $mail->addAddress(get_option("admin_email"));  
    $mail->addCC(get_option("admin2_email_something"));
    $mail->isHTML(true);   // Set email format to  HTML
    $mail->Subject = trim($_POST[your_subject]);
    $mail->Body    = stripslashes(trim($_POST[your_message]));
    if(!$mail->send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}

修复了所有故障。。只要把这个放在header参数后面。。

$email = mail(get_option("admin_email"),trim($_POST[your_subject]),stripslashes(trim($_POST[your_message])),$headers, "-fsender@domain.com");