通过CodeIgniter Mysource代码中的电子邮件进行Pdf附件
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('test@gmail.com');
$this->email->to($useremail);
$this->email->cc('');
$this->email->subject('pdf');
$this->email->message($message);
$this->email->attach('public_html/invoicepdf/171.pdf');
$mailsucc = $this->email->send();
我试过这个,但没有工作
$this->email->attach('public_html/invoicepdf/171.pdf');
我还用URL替换路径。
答案 0 :(得分:0)
您可以使用
发送附件 base_url
方法。在下面的代码中,我使用SMTP发送邮件 附件。
完美的工作。
您只需指定$email_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'yourmail@gmail.com', // change it to yours
'smtp_pass' => 'mypasswords', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
// Defined Attachment file using variable
$atch=base_url().'html/images/logo.png';
$this->load->library('email', $email_config);
$this->email->set_newline("\r\n");
$this->email->from('test@gmail.com', 'Rudra'); // email From
$this->email->to('mailtosend@gmail.com'); // eMail to send
$this->email->subject('Mail with Attachment'); // Subject
$this->email->message("This is mail with Attachment file using CodeIgniter."); // Message
$this->email->attach($atch); // Attachment file defined using variable
$maill=$this->email->send(); // send mail
if($maill>0)
{
echo 'Email sent.'; // success
}
else
{
show_error($this->email->print_debugger());
}
来定义附件文件路径
<强>控制器强>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1 = "string1";
reverse(s1.begin(),s1.end());
cout << s1;
return 0;
}