wordpress中的PHP编译器是否有更干净的代码。。?
作为此问题的扩展版本: 我们不能在一个数组中使用PHPmailer的所有配置吗wordpress中的PHP编译器是否有更干净的代码。。?,php,arrays,wordpress,Php,Arrays,Wordpress,作为此问题的扩展版本: 我们不能在一个数组中使用PHPmailer的所有配置吗 $mail = array( 'SMTPAuth' => true, 'Host' => 'smtp.millicenthotel.com', 'Port' => 25, 'Username' => 'info@millicenthotel.com', 'Password' => '
$mail = array(
'SMTPAuth' => true,
'Host' => 'smtp.millicenthotel.com',
'Port' => 25,
'Username' => 'info@millicenthotel.com',
'Password' => 'gboskeritysoldier1'
);
我试过这样的东西,但没用。我正在寻找一种更干净的方法
提前感谢。您有一个名为 抄本: wp_mail函数依赖PHPMailer类发送电子邮件 通过PHP的邮件功能。phpmailer_init操作钩子允许 钩住phpmailer对象并传入您自己的参数 示例():
你有一个动作钩叫做 抄本: wp_mail函数依赖PHPMailer类发送电子邮件 通过PHP的邮件功能。phpmailer_init操作钩子允许 钩住phpmailer对象并传入您自己的参数 示例():
我确信您可以编辑构造函数以接受配置/选项数组。@PatrickQ-确实可以-但直接使用操作挂钩配置它。请参阅Answer我确信您可以编辑构造函数以接受配置/选项数组。@PatrickQ-确实可以-但直接使用操作挂钩配置它。如果有效,请参阅answerSo对于您来说,您可能希望通过单击投票下方的小“
”V”
符号来获得答案,以便将问题标记为已回答。因此,如果它对您有效,您可能希望通过单击投票下方的小“”V”
符号来获得答案,以便将问题标记为已回答。
add_action( 'phpmailer_init', 'my_phpmailer_example' );
function my_phpmailer_example( $phpmailer ) {
$phpmailer->IsSMTP(); //switch to smtp
$phpmailer->Host = 'smtp.example.com';
$phpmailer->Port = 25;
$phpmailer->Username = 'yourusername';
$phpmailer->Password = 'yourpassword';
}