【问题标题】:unable to sent email from codeigniter无法从 codeigniter 发送电子邮件
【发布时间】:2013-03-10 20:32:49
【问题描述】:

我的申请在线。

我已经编写了以下代码,用于向指定的电子邮件地址发送电子邮件。

我收到“电子邮件发送成功”的 Flash 消息,但我无法接收电子邮件。可能是什么原因。请帮帮我!

controller.php:

 if ($this->form_validation->run() === TRUE)
      {   $this->load->library('email');
          $name=$this->input->post('fullname');
          $sendersemail=$this->input->post('email');
          $fromcountry=$this->input->post('countryname');
          $message=$this->input->post('contactdetails'); 
          $this->email->from($sendersemail, $name.'From'.$fromcountry);
          $this->email->to('a@gmail.com'); 
          $this->email->cc('b@yahoo.com'); 
          $this->email->bcc('c@gmail.com');  
          $this->email->subject('New Customer Contact from thmywebsite.com');
          $this->email->message($message);  
          $this->email->send(); 
          $this->session->set_flashdata('msg', 'Thankyou for contacting us .We will shortly  reply back on this ('.$this->input->post('email').') email ');
           redirect(current_url());
      }

更新:保留调试器后:我得到这样的输出

    Your message has been successfully sent using the following protocol: mail
    From: 
    Return-Path: 
    Cc: thbestbookfinder@yahoo.com
    Bcc: thebestbookfinder@gmail.com
    Reply-To: "lovesangprince@yahoo.com" 
    X-Sender: lovesangprince@yahoo.com
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <513e08c9def93@yahoo.com>
    Mime-Version: 1.0
    Content-Type: multipart/alternative; boundary="B_ALT_513e08c9defa1"


    =?utf-8?Q?New_Customer_Contact_from_thebestbookfinder.com?=
    This is a multi-part message in MIME format.
    Your email application may not support this format.

    --B_ALT_513e08c9defa1
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit

    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf
    dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf
    dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf
    dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf
    dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak


    --B_ALT_513e08c9defa1
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: quoted-printable

    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak=
    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak=
    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak=
    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak=
    asd fsfsfs d hjfsdjf dsakasd fsfsfs d hjfsdjf dsak

    --B_ALT_513e08c9defa1--

【问题讨论】:

  • from 地址应该解析到您从中发送消息的服务器。输入的地址使用reply-to
  • 在此 $this->session->set_flashdata('msg', '感谢您与我们联系。我们将尽快回复此 ('.$this->input->post('电子邮件').') 电子邮件');放这个并发布结果 echo $this->email->print_debugger();
  • @Pekka웃 抱歉,我没有得到您的解释。请稍微解释一下。
  • from 地址应该是来自您的服务器的地址,而不是用户输入的任意地址。无效的from 地址可能会作为垃圾邮件被过滤掉。我会先做$this-&gt;email-&gt;from("myemail@mydomain.com"); 然后$this-&gt;email-&gt;replyTo($sendersemail, $name.'From'.$fromcountry);(我假设这个类有一个replyTo() 方法)
  • 你提到了$this-&gt;email-&gt;replyTo($sendersemail, $name.'From'.$fromcountry);,replyTo 方法已经在 codeigniter 库中可用,还是我必须自己编写?如果您通过修改我上面的代码将其发布为答案,将会更有帮助。

标签: php codeigniter email


【解决方案1】:

尝试将此代码放在 $this->send->email 下方

echo $this->email->print_debugger();

如果电子邮件发送到那里,请检查您的垃圾邮件

【讨论】:

    猜你喜欢
    • 2012-12-05
    • 1970-01-01
    • 2023-03-27
    • 2013-08-13
    • 2012-12-16
    • 2013-06-15
    • 2012-10-31
    相关资源
    最近更新 更多