[英]when i am trying to send mail from server getting fatal error?
this is my mail script trying to send mail from my server. 这是我的邮件脚本,试图从服务器发送邮件。
<?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
?>
When i am trying to run this script in my godaddy server i am getting fatal error: Fatal error: Call to undefined function sendMail() in /home/content/99/7916299/html/EMRXXX/EMRnew/Patient/sendmail1.php on line 13 当我尝试在Godaddy服务器中运行此脚本时,出现致命错误:致命错误:调用/home/content/99/7916299/html/EMRXXX/EMRnew/Patient/sendmail1.php中的未定义函数sendMail() 13行
Thank you in advance, Ramsai 预先谢谢拉姆赛
Fatal error: Call to undefined function sendMail() 致命错误:调用未定义的函数sendMail()
Means you forgot to include your sendMail()
user function. 意味着您忘记了包括
sendMail()
用户功能。 Because there is no native php sendMail()
function... 因为没有本机php
sendMail()
函数...
You should use the native mail() function and setup your server to use sendmail (smtp) within your php.ini file: 您应该使用本机mail()函数并将服务器设置为在php.ini文件中使用sendmail(smtp):
mail($to,$subject,$content,$headers);
No 1. you can use native function of PHP called mail(). 否1.您可以使用PHP的本机函数mail()。 for more details http://www.w3schools.com/php/php_mail.asp
有关更多详细信息,请访问http://www.w3schools.com/php/php_mail.asp
here you have to setup SMPT details in your php.ini file or u can overwrite itfrom your code. 在这里,您必须在php.ini文件中设置SMPT详细信息,或者您可以从代码中覆盖它。
No 2. Use PHPMailer Library.Very much easy to integrate. 否2.使用PHPMailer Library。非常易于集成。 you can get it from http://code.google.com/a/apache-extras.org/p/phpmailer/
您可以从http://code.google.com/a/apache-extras.org/p/phpmailer/获取
Have you included some php library which supports sendmail? 您是否包含一些支持sendmail的php库?
If you're trying to use the OS command sendmail, this won't work like that. 如果您尝试使用OS命令sendmail,则将无法正常工作。
PHPs mail function isn't recommended so use something like PHPMailer . 不建议使用PHP的邮件功能,因此请使用PHPMailer之类的东西。
You need to find the php file in which defination of method sendMail is written and then include it . 您需要找到写有sendMail方法定义的php文件,然后将其包括在内。 If by chance its in same directory then simply add this line on top
如果偶然在同一目录中,则只需在顶部添加此行
require_once 'sendmail.php' ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.