dongxia9620 2014-04-22 20:59
浏览 34
已采纳

在wordpress中有没有更清晰的PHPmailer代码..?

As a extended version to this question : PHPMailer(): Called Mail() without being connected

Can't we use all the configurations for the PHPmailer in an array, Some thing like this:

$mail = array(
        'SMTPAuth'  => true,
        'Host'      => 'smtp.millicenthotel.com',
        'Port'      => 25,
        'Username'  => 'info@millicenthotel.com',
        'Password'  => 'gboskeritysoldier1'
        );

I tried something like this and it not work. I'm looking for a cleaner way of doing this.

Thanks in Advance.

  • 写回答

1条回答 默认 最新

  • dry69034 2014-04-22 21:14
    关注

    you have an action hook called phpmailer_init

    from codex :

    The wp_mail function relies on the PHPMailer class to send email through PHP's mail function. The phpmailer_init action hook allows you to hook to the phpmailer object and pass in your own arguments.

    example ( codex again ):

    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';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)