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

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

报告相同问题?

悬赏问题

  • ¥15 openwrt双栈NAT
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用