真奇怪的Php Mail ::工厂问题

时间:2013-08-19 02:51:32

标签: php email smtp

我有这个非常奇怪的问题,我感到困扰,不知道如何解决它!

我在这里使用的示例代码Wroks并正确地向我发送电子邮件!

<?php
require_once "Mail.php";

$from = "Web Master <contact@sample.com>";
$to = "bob <sample@sample.com>";
$subject = "Test email using PHP SMTP\r\n\r\n";
$body = "This is a test email message";

$host = "mail.emailsrvr.com";
$username = "sample@sample.com";
$password = "11111";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

但是,当我把这个代码放入电子邮件密码提醒PHP代码时,它停止工作! 我把代码放在最前面或你点击发送按钮的地方 触发,没有任何作用,我不明白为什么! 有趣的是,如果我慢慢复制代码的一部分并且它工作,我有它的工作 关于第一个或两个电子邮件,它会在...之后停止工作。

电子邮件脚本之前的reminder.php之前的代码

<?php
ini_set("display_errors","1");
ini_set("display_startup_errors","1");
if(get_magic_quotes_runtime())
{
    set_magic_quotes_runtime(false);
}

include("include/dbcommon.php");

$cEmailField = "email";
$reminded=false;
$strSearchBy="username";

include('libs/Smarty.class.php');
$smarty = new Smarty();

$strUsername="";
$strEmail="";
$strMessage="";

$conn=db_connect();
//  Before Process event
if(function_exists("BeforeProcessRemindPwd"))
    BeforeProcessRemindPwd($conn);

拜托!如果您对解决方案有任何想法吗?

1 个答案:

答案 0 :(得分:0)

mail("sample@sample.com","Test email","test body here");

检查这是否有效?