当我试图从服务器发送邮件致命的错误?

时间:2012-05-28 07:49:52

标签: php sendmail

这是我的邮件脚本,试图从我的服务器发送邮件。

<?php
$subject = 'This is an HTML email.';
$smtp_server = 'smtp.mydomain.com';
$from = $smtp_username = 'info@mydomail.com';
$smtp_password = 'mypassword';
$html = 'This is an <strong>HTML</strong> <i>formatted</i> email!';
$text = strip_tags($html);
$to = 'ramsai.php@gmail.com';
//$cc = array('foo@example.com');
//$bcc  array('bar@example.com', 'baz@example.com');

// send the message
$result = sendMail($subject, $smtp_server, $smtp_username, $smtp_password, $html, $text, $to);

// check to see if the message was sent properly
if ($result !== true) {
    echo 'There was an error sending the message. ('.$result.')';
} // end if the message was not sent properly
else {
    echo 'Message sent successfully.';
} // end else the message was sent properly


?>

当我试图在我的godaddy服务器中运行此脚本时,我遇到了致命的错误: 致命错误:在第13行的/home/content/99/7916299/html/EMRXXX/EMRnew/Patient/sendmail1.php中调用未定义的函数sendMail()

提前谢谢你, Ramsai

4 个答案:

答案 0 :(得分:3)

致命错误:调用未定义的函数sendMail()

表示您忘记添加sendMail()用户功能。因为没有原生的php sendMail()函数......

您应该使用本机mail()功能并设置服务器以在 php.ini 文件中使用sendmail(smtp):

mail($to,$subject,$content,$headers);

答案 1 :(得分:2)

否1.您可以使用名为mail()的PHP的本机函数。有关详情http://www.w3schools.com/php/php_mail.asp

在这里你必须在你的php.ini文件中设置SMPT细节,否则你可以从你的代码中覆盖它。

否2.使用PHPMailer Library。很容易集成。 你可以从http://code.google.com/a/apache-extras.org/p/phpmailer/

获得它

答案 2 :(得分:1)

你是否包含了一些支持sendmail的php库?

如果您正在尝试使用操作系统命令sendmail,那么这将无法正常工作。

不建议使用PHP邮件功能,因此请使用PHPMailer

答案 3 :(得分:0)

你需要找到写入sendMail方法定义的php文件然后包含它。如果它偶然在同一目录中,那么只需在顶部添加此行

require_once 'sendmail.php' ;
相关问题