[英]Accept email address from user and send email to that address
public function send_mail() {
$this->email->from('your@email.com', 'My Name');
$this->email->to('to@email.com');
$this->email->cc('cc@email.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
}
我正在嘗試使用codeigniter電子郵件功能,但似乎無法收到測試郵件,但它表示已成功發送了郵件,但沒有任何新信息,因此我對此問題感到困惑,$ this-> load ->庫('電子郵件'); 也裝了,任何幫助謝謝!
好的,謝謝您的回答,我已經添加了ff代碼,現在可以使用了,
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'your email',
'smtp_pass' => 'your password'
);
現在我的問題是我該如何編輯上面的代碼以接受來自用戶的“收件人”電子郵件?
好吧,我已經做了“至”部分,就像這樣
$this->email->to($point->email);
再次需要“消息”部分的幫助,我需要將來自用戶的數據放入“消息”部分,我嘗試了我在“至”部分所做的操作,但它僅接受一項,我需要多項,謝謝
它在沒有任何$ config的linux服務器中可以正常工作。
請閱讀此內容以設置其他協議
在調用函數send_mail()
的部分中, send_mail()
電子郵件地址和其他數據作為參數傳遞給該函數; 像這樣的東西:
$to = $point->email;
$msg = $point->message; // the message part
$phone = $point->phone; // phone number
$address = $point->address; // postal address
$this->send_email($to, $msg, $phone, $address);
然后稍微修改send_mail()
函數為:
// $to_address will contain the value stored in $to, i.e. "abc@def.com" in this case
public function send_mail($to_address, $body_message, $phone_no, $addr) {
// can make use of extra data like phone number, address in here
$this->email->from('your@email.com', 'My Name');
$this->email->to($to_address);
$this->email->message($body_message);
.
.
.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.