1

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

<?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 服务器中运行此脚本时,我收到致命错误:致命错误:调用 /home/content/99/7916299/html/EMRXXX/EMRnew/Patient/sendmail1.php 中的未定义函数 sendMail()第 13 行

提前谢谢你,拉姆塞

4

4 回答 4

3

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

意味着您忘记包含您的sendMail()用户功能。因为没有原生的phpsendMail()函数...

您应该使用本机mail()函数并将服务器设置为在php.ini文件中使用 sendmail (smtp) :

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

于 2012-05-28T07:59:24.553 回答
2

不 1. 你可以使用 PHP 的原生函数 mail()。更多详情http://www.w3schools.com/php/php_mail.asp

在这里,您必须在您的 php.ini 文件中设置 SMPT 详细信息,或者您可以从您的代码中覆盖它。

否 2. 使用 PHPMailer 库。非常容易集成。你可以从http://code.google.com/a/apache-extras.org/p/phpmailer/得到它

于 2012-05-28T08:08:18.130 回答
1

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

如果您尝试使用操作系统命令 sendmail,则不会这样。

不建议使用 PHP 邮件功能,因此请使用PHPMailer之类的东西。

于 2012-05-28T07:50:59.420 回答
0

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

require_once 'sendmail.php' ;
于 2012-05-28T07:58:25.353 回答