调用未定义方法的PHPMailer异常PHPMailer :: SetFrom() [英] PHPMailer erroring out with Call to undefined method PHPMailer::SetFrom()
问题描述
这里我的错误
调用未定义的方法PHPMailer :: SetFrom()
和我的脚本
require_once( 'INC / PHPMailer的/ class.phpmailer.php');
$ mail = new PHPMailer(); //默认使用phpmail()
$ body = $ message;
$ mail-> SetFrom('tell-a-friend@domain.com','告诉朋友');
$ mail-> AddAddress($ to_email,$ to);
$ mail-> Subject =告诉朋友;
$ mail-> MsgHTML($ body);
$ mail-> Send();
任何想法?
编辑
证明在我的phpmailer版本中不存在SetFrom()函数,我可以使用
$ mail-> From ='';
$ mail-> FromName ='';
小心点,PHPMailer有多个版本。我从来不知道哪个是哪个。无论如何,PHPMailer 5.1的此下载肯定包含一个 setFrom
方法:
public function SetFrom($ address,$ name ='',$ auto = 1){
Hay I'm using PHPMailer to send some simple emails, however the function SetFrom() doesn't seem to work, even though the code I'm using is straight from phpmails docs (http://phpmailer.worxware.com/index.php?pg=examplebmail)
Here my error
Call to undefined method PHPMailer::SetFrom()
and my script
require_once('inc/phpmailer/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = $message;
$mail->SetFrom('tell-a-friend@domain.com', 'tell a friend');
$mail->AddAddress($to_email, $to);
$mail->Subject = "tell a friend";
$mail->MsgHTML($body);
$mail->Send();
Any ideas?
EDIT
turns out the SetFrom() function doesnt exist in my version of phpmailer, i can set these values using
$mail->From = '';
$mail->FromName = '';
Careful, there are multiple versions of PHPMailer around. I've never quite understood which is which. Anyway, this download of PHPMailer 5.1 definitely contains a setFrom
method:
public function SetFrom($address, $name = '',$auto=1) {
这篇关于调用未定义方法的PHPMailer异常PHPMailer :: SetFrom()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!