【问题标题】:how to configure SMTP in codeigniter application?如何在 codeigniter 应用程序中配置 SMTP?
【发布时间】:2017-06-17 20:11:38
【问题描述】:

我是 php codeigniter 中 SMTPsendmailmail() 函数的新手。

我正在尝试在我的 codeigniter 应用程序中配置 SMTP 邮件协议。为单个用户进行所有设置、SMTP 端口、发件人邮件、用户 ID、密码,即admin@example.com。它工作正常。

我的问题是,可以在单个应用程序中设置两个 SMTP 用户帐户吗?

比如我想设置info@example.com和admin@example.com,这样这两个用户就可以给客户发邮件了。

【问题讨论】:

  • 你能给我看看你的sendmail功能代码片段吗?
  • 一切皆有可能,除非您在普通 CPU 上谈论量子力学。但这一切都需要代码,我没有看到任何代码。

标签: php codeigniter email smtp


【解决方案1】:

您只能通过更改配置来使用它:就像

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxx', // First user authenticate
    'smtp_pass' => 'xxx',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'yyy', // Second user authenticate
    'smtp_pass' => 'zzzz',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

但只有一件事是您必须在服务器上配置您的两个邮件用户。谢谢

【讨论】:

    猜你喜欢
    • 2018-08-03
    • 2016-07-26
    • 1970-01-01
    • 2018-05-14
    • 2023-03-12
    • 2018-01-25
    • 2013-10-14
    • 2018-10-24
    • 1970-01-01
    相关资源
    最近更新 更多