Email cakephp2如何使用gmail smtp将电子邮件动态发送到关闭的邮件列表
在php或cakephp中是否存在使用smtp发送电子邮件的方法,以便我可以将电子邮件发送到封闭/内部邮件列表。e、 g: 在我的公司,我们有一个电子邮件列表:appsteam@company.com,只有在使用xxx@company.com电子邮件。在该电子邮件之外,它将被阻止。因此,在cakephp中,是否有人可以通过某种方式获取用户凭证并在公司下发送电子邮件,或者如果是google group,是否可以通过gmail电子邮件发送 我想我真正想要的是,如何设置cakephp电子邮件,使其发送就像我直接从电子邮件服务器发送一样,如果我使用gmail,那么我希望它看起来像gmail(标题等) 最终的代码将要做的是,我将从用户那里获取他们电子邮件的凭据,并使用该凭据发送邮件。这是我的AbcComponent.php代码Email cakephp2如何使用gmail smtp将电子邮件动态发送到关闭的邮件列表,email,cakephp,smtp,gmail,cakephp-2.0,Email,Cakephp,Smtp,Gmail,Cakephp 2.0,在php或cakephp中是否存在使用smtp发送电子邮件的方法,以便我可以将电子邮件发送到封闭/内部邮件列表。e、 g: 在我的公司,我们有一个电子邮件列表:appsteam@company.com,只有在使用xxx@company.com电子邮件。在该电子邮件之外,它将被阻止。因此,在cakephp中,是否有人可以通过某种方式获取用户凭证并在公司下发送电子邮件,或者如果是google group,是否可以通过gmail电子邮件发送 我想我真正想要的是,如何设置cakephp电子邮件,使其发送
/*
* Abc components
*/
class AbcComponent extends Component {
public $options = array();
/**
* Constructor
**/
public function __construct(ComponentCollection $collection, $options = array()){
parent::__construct($collection,$options);
$this->options = array_merge($this->options, $options);
}
public function send_link ($user_email = null, $recipients = null, $subject = null, $message = null, $group_id = null, $user_id = null, $email_id = null, $download_password = null) {
$final_subject = $subject;
$final_recipients = $recipients;
$final_message = $message;
App::uses('CakeEmail', 'Network/Email');
$recipients = str_replace(' ', '', $recipients);
$recipients = explode(',', $recipients);
$recipient_queue_num = 1;
//Send the email one by one
foreach ($recipients as $recipient) :
$email = new CakeEmail();
$email->delivery = 'smtp';
//$email->from($user_email);
$email->from('xxxxx@gmail.com');
$email->to($recipient);
$email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'xxxxx@gmail.com', //this will be later grab from dbase based on user
'password'=>'password',
);
$email->subject($final_subject);
$email->template('download_link_email');
$email->emailFormat('both');
$email->viewVars(array('final_message' => $final_message));
if($email->send()) {
debug('email is sent');
} else {
debug('email is not sent');
}
//queue number increase for hashing purpose
$recipient_queue_num++;
endforeach;
}
后来
$email = new CakeEmail();
在尝试访问“新对象”语句之前,它在哪里?
你不能不使用它。
您还同时使用$this->Email和$Email。这可能是您的错误(复制和粘贴错误)
“重载属性的间接修改”通常是试图访问的未声明对象的指示符
后来
$email = new CakeEmail();
在尝试访问“新对象”语句之前,它在哪里?
你不能不使用它。
您还同时使用$this->Email和$Email。这可能是您的错误(复制和粘贴错误)
“间接修改重载属性”通常是试图访问的未声明对象的指示符。您是对的,错误现在消失了。你知道为什么如果我发送一封电子邮件,它会工作得很好吗(abc@test.com),但它不适用于邮件列表,例如(appsteam@test.com)也许你没有这样做的权限(mailinglist只能允许特定的发件人),但这超出了你的问题范围。你是对的,错误现在消失了。你知道为什么如果我发送一封电子邮件,它会工作得很好吗(abc@test.com),但它不适用于邮件列表,例如(appsteam@test.com)也许您没有这样做的权限(mailinglist可能只允许特定的发件人),但这超出了您的问题范围。
$this->Email = new CakeEmail();
$this->Email->delivery = ...
...