繁体   English   中英

当我尝试从服务器发送邮件时遇到致命错误?

[英]when i am trying to send mail from server getting fatal error?

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

<?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行

预先谢谢拉姆赛

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

意味着您忘记了包括sendMail()用户功能。 因为没有本机php sendMail()函数...

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

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

否1.您可以使用PHP的本机函数mail()。 有关更多详细信息,请访问http://www.w3schools.com/php/php_mail.asp

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

否2.使用PHPMailer Library。非常易于集成。 您可以从http://code.google.com/a/apache-extras.org/p/phpmailer/获取

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

如果您尝试使用OS命令sendmail,则将无法正常工作。

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

您需要找到写有sendMail方法定义的php文件,然后将其包括在内。 如果偶然在同一目录中,则只需在顶部添加此行

require_once 'sendmail.php' ;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM