简体   繁体   中英

CakePHP and masking email sender

I am currently using a function called send:

    public function send(){


     if ( !empty($this->request->data) ) {
    $email = new CakeEmail('default');
    $email->from(array($this->Auth->user('email') => $this->Auth->user('username')))
    ->to(array('helpdesk@example.com'))
    ->subject($this->request->data['Ticket']['subject'])
    ->send(array($this->request->data['Ticket']['issue']));

    $this->Session->setFlash('Email Sent Successfully', 'default', array('class' => 'message update span9'));
    $this->redirect(array('action' => 'index'));

    }

to Send emails to our helpdesk and deposit them into their database. All is working EXCEPT the FROM always shows the username/email address from the configuration options. It is not masking the email with the users email.. I need this to happen so that we know who is having the support issue.

Does anyone have a suggestion here on what to do?

*Addition

This is an intranet application and thus we have an authenticated GENERIC USER using smtp settings. This is not spamming, we just want to know which user the Help Desk ticket came from when inserting to the DB.

Why are you using the Config default anyway?

If you use $email = new CakeEmail(); , does the email sent references the Authenticated User email info.

Also, you should always use $email->sender('support@yourcompany.com', 'Your Company Support'); . This ensures that if there is an issue the problem get redirected to you and not the user, your app is sending an email on his/her behalf.

I have that setup in my account and it works just fine. To Mark's point, it may not be legal (although, that does not seem to be your issue), but I know it is possible as I have currently a system setup that works with whatever email I want. I do not use any Config and also I do not use any SMTP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM