Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

致命错误: Method name must be a string #5

Open
ChenZhenJie29770 opened this issue Feb 25, 2020 · 1 comment
Open

致命错误: Method name must be a string #5

ChenZhenJie29770 opened this issue Feb 25, 2020 · 1 comment

Comments

@ChenZhenJie29770
Copy link

use mailer\tp51\Mailer;

$mailer = Mailer::instance();
$mailer->from('10086@qq.com@qq.com', 'cattong')
    ->to('your-mail@domain.com')
    ->subject('纯文本测试')
    ->text('欢迎您使用think-mailer')
    ->send();

使用的是这个代码,但是提示错误,这个是什么问题?
Transport.php line 120
致命错误: Method name must be a string
in Transport.php line 120
at Transport->getDriver(null) in Mailer.php line 409

@cattong
Copy link
Owner

cattong commented Feb 25, 2020

要有配置文件,
在配置文件里配置如下信息, 可以配置在 mail.php 或 config.php 文件中, 但要保证能通过 mail.driver, mail.host 访问到配置信息, 内容如下:

return [
'driver' => 'smtp', // 邮件驱动, 支持 smtp|sendmail|mail 三种驱动
'host' => 'smtp.qq.com', // SMTP服务器地址
'port' => 465, // SMTP服务器端口号,一般为25
'addr' => '', // 发件邮箱地址
'pass' => '', // 发件邮箱密码
'name' => '', // 发件邮箱名称
'content_type' => 'text/html', // 默认文本内容 text/html|text/plain
'charset' => 'utf-8', // 默认字符集
'security' => 'ssl', // 加密方式 null|ssl|tls, QQ邮箱必须使用ssl
'sendmail' => '/usr/sbin/sendmail -bs', // 不适用 sendmail 驱动不需要配置
'debug' => true, // 开启debug模式会直接抛出异常, 记录邮件发送日志
'left_delimiter' => '{', // 模板变量替换左定界符, 可选, 默认为 {
'right_delimiter' => '}', // 模板变量替换右定界符, 可选, 默认为 }
'log_driver' => '', // 日志驱动类, 可选, 如果启用必须实现静态 public static function write($content, $level = 'debug') 方法
'log_path' => '', // 日志路径, 可选, 不配置日志驱动时启用默认日志驱动, 默认路径是 /path/to/think-mailer/log, 要保证该目录有可写权限, 最好配置自己的日志路径
'embed' => 'embed:', // 邮件中嵌入图片元数据标记
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants