I am having problem on sending email via cake php 2.7. Well, the email gets forwarded to the desired email address but there is problem in getting sender email address, as I am getting configuration email address in the place of sender email address. I have problem in getting how to fix this issue. It would be grateful if anybody could suggest anything regarding the issue.
Some parts of code are:
pages controller
public function sendEmail($data) {
$email = new CakeEmail();
$email->config('gmail');
$email->emailFormat('html');
$email->sender($data['User']['email_address'],$data['User']['name']);
$email->from(array($data['User']['email_address'] => $data['User']['name']));
$email->to('configuration_email');
$email->replyTo($data['User']['email_address']);
$email->subject($data['User']['subject']);
$message = 'Name: '.$data['User']['name'].'<br> How Did You Hear: '. $data['User']['how_did_you_hear'].
'<br>Message: '.$data['User']['body'];
if ($email->send($message))
{
return true;
}else {
return false;
}
}
email.php
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'configuration_email',
'password' => 'password',
'transport' => 'Smtp'
);
'From' field is using configuration email instead of using $data['User']['email'].
Thank you in advance!
Gmail lets you send messages on behalf of an email address different from your Gmail address only if you already own that email account and it is properly registered in your Gmail account.
Instructions are described in Gmail: Send mail from a different address or alias:
I'm a Gmail or Google Apps user sending from an external address.
Select Settings.
Open your other account and either click the link in the message Gmail sent or enter the confirmation code in the Accounts and Import section of your Gmail settings.