Cakephp email sending email with "via" near to sender email id - cakephp

Im fed up with this problem, tried all the things and measures but the problem remains. Whenever im sending an Email using cakephp 2.x im getting a "via" xyzabc.com , near to the sender's email id in email inbox.
Here is my code -
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->from('noreply#'.env('SERVER_NAME'));
$Email->replyTo('noreply#'.env('SERVER_NAME'));
$Email->sender('noreply#'.env('SERVER_NAME'));
$Email->to('myemailid#gmail.com');
$Email->subject('Account activation Link');
$username="Katrina";
$link="http://mywebsite.com/users/account_activation/myemailid#gmail.com/jkasjfi3ed34";
$Email->viewVars(array('user_name' => $username,'link'=>$link));
$Email->template("user/new_user_registered");
$Email->emailFormat("html");
$Email->send();
Please help with the issue, what is wrong with my code?

Related

Sending Email Via CakePHP - Configuration email override the sender email

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.
Click the gear in the top right .
Select Settings.
Click the Accounts and Import tab.
Under Send mail as, click Add another email address.
In the 'Email address' field, enter your name and alternate email address you own.
Enter the SMTP server (e.g. smtp.domain.com), your username on that domain, and your password for that account. You may also need to adjust your port setting or SSL setting (talk to your other ISP if you need this information).
Click Add account >>
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.
If Gmail sent a verification email and you didn’t receive it, try checking your Spam or Bulk Mail folders for a message from account-verification-noreply#google.com to see if the email ended up in there.

Email is not going to deliever on yahoo server

I am using cakephp, and sending email through cakeemail with smtp. My hosting is on 1and1.com. Email is going to deliver on gmail but not on yahoo and hotmail.
Then I try the PHPMailer on same server and its email was going to deliver on gmail and hotmail as well. But unfortunatly I am unable to use PHPMailer with cakephp. I have try two tutorial but fails. One of them is here.
I will prefer to fix the problem with cakeemail, if some one can help regarding this.
Or if can get solution with PHPMailer for cakephp that is also ok.
Here is the my code
$email = new CakeEmail();
$email->smtp = array(
'port'=>'25',
'timeout'=>'30',
'host' => 'smtp.1and1.com',
'username'=>'quote#xxxxxx.com',
'password'=>'xxxxxx_',
'client' => 'smtp.1and1.com' ,
'transport' => 'Smtp'
);
$email->from(array('xxxx#a-xxxx.com' => 'A-Best Auto Parts Quote'));
$email->to("xxxx#yyy.com");
//$email->bcc("xxxx#yyy.com");
$email->subject('My Test Subject');
$email->emailFormat('html');
$body="the test message for email"
$email->send($body);

not receive email in google app engine java

I'm writing code for receive email and change into todo. I received fresh email and converted todo but I sent forward email or reply email app engine not receive the email. What's the problem. I used session and getdefaultinstance that's all rest of the code same as receive email code.please do the needful.thanks
IN SERVLET Properties props = new Properties();
Session email = Session.getDefaultInstance(props, null);
try
{
MimeMessage message = new MimeMessage(email,req.getInputStream());
String summary = message.getSubject();
String description = getText(message);
Address[] addresses = message.getFrom();
User user = new User(addresses[0].toString(), "gmail.com");
Date date =new Date();
DaoComments.INSTANCE.add(addresses[0].toString(),lid,date,description,"selcom‌​ment"); 
}catch (Exception e)
{ e.printStackTrace();
}
IN WEB.XML
EmailTicket
com.cloudnowtech.EmailAgentServlet
EmailTicket
/_ah/mail/*
IN appengine-web-app
mail
HERE I'M SENDING THE CODE. PLEASE CORRECT IT – 
An important part of sending email is to, well, to send it. Perhaps you missed this part:
// Hand the message to the default transport service for delivery.
Transport.send(msg);
If you take a peek over on the right there ---->,
Wander the related questions for yourself and you should find some helpful tidbits.
Welcome to StackOverflow and have a nice day.
It looks like this:
I got answer. there is no setting for forward and reply email to receive. I declared field as String but reply or forward mail size as more than 500 character. so change as Text. now its working fine. thanks for all.
Thanks
Murugavel

multiple mail recipients with CakePHP using bcc (the right insert method)

i use the php framework cakePHP to create a web app. There,i want the user to insert in a field as many email addresses as he desires and by hitting the Send button,a message would be emailed to all of the emails.
To achieve that,i have to use bcc.
My problem is that i do not know how can i "read" from the user his email addresses in the right form so that i use them in bcc.
Till now,i have a variable $to = $this->request->data['Mail']['to']; ,where 'Mail' is my model name,and in case the user inserts just one email address,the recipient receives the mail correctly. But how can i enable it to receive multiple email addresses (maybe in an array??) so that i use the variable $to at this piece of code:
$Email = new CakeEmail();
$Email->from($from)
->**bcc($to)**
->subject($subject)
->send($message);
and help is welcomed :)
thank you in advance!
There is the API ( http://api.cakephp.org/2.3/class-CakeEmail.html#_addBcc ) and the code is open source. They all provide the information you are looking for.
If you open the class CakeEmail you will find ( https://github.com/cakephp/cakephp/blob/master/lib/Cake/Network/Email/CakeEmail.php#L482 ):
public function addBcc()
which is different from bcc() since it can be used multiple times to add multiple bcc addresses.

PHP mail() not sending, but no exception thrown

I'm using CakePHP to send an email. My controller code looks like:
if ($this->User->save($this->request->data)) {
$email = new CakeEmail();
$email->from(array('noreply#mydomain.com' => 'My Domain'));
$email->to($this->request->data['User']['email']);
$email->subject('My Domain Confirmation');
$email->replyTo('noreply#mydomain.com');
$email->sender('noreply#mydomain.com', 'My Domain');
$email->emailFormat('html');
$email->template('confirmation');
$email->send();
$email->viewVars(array(
'name' => $this->request->data['User']['username'],
'id' => $this->User->getLastInsertID(),
'code' => $this->request->data['User']['confirm_code']));
}
I also included at the top of this controller:
App::uses('CakeEmail', 'Network/Email');
If I print_r on $email->send(), I get:
Array
(
[headers] => From: My Domain
Reply-To: noreply#mydomain.com
X-Mailer: CakePHP Email
Date: Thu, 23 Feb 2012 00:40:00 -0800
Message-ID: <4f45fb60a0fc46cd926f305a32396397#mydomain.com>
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
[message] =>
Hi there,
Welcome to my site! While you can now vote on submissions and leave comments, your own submissions will be screened and not appear to the public until you click on the confirmation link below:
Click here to confirm your account
We hope to see you around and thanks for joining the community!
So it's obviously using my html email template and passing the right variables to it, and throwing no exceptions. So I decided to just do a basic mail() test within one of my view files e.g.:
$to = "mytestemail#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Which echoed "Mail Sent.", but nothing actually came to my mailbox. I checked my file in /var/spool/mail/root and the last email sent was on the same server on Jan. 9, 2012. So it's definitely worked before. I just recently upgraded to Cake 2.0, but this doesn't explain why plain ol' mail() isn't working.
What other debugging methods can I check to make sure it's not my server preventing the email from being sent?
PHP's mail() won't throw any exceptions. You need to check the return status. If that's false, then your MTA isn't accepting mail. Even if it returns true, that doesn't actually mean much of anything.
Take a look at the mail logs in /var/log/. Hopefully those can help you figure out more.
also check your firewall settings. sometimes it stops all outgoing smtp requests if not from specific sources.
The server you are running your Cake app on probably requires (SMTP) authentication before it allows you to send anything, which is a pretty common configuration.
Copy the app/Config/email.php.default file to app/Config/email.php and adjust it to match your setup (usually it's just localhost and you can use one of your mailbox logins for authentication).
Also see the book on this subject.

Resources