CakePHP cannot get multiple emails send after a previous execution..
this is an example:
$Email = new CakeEmail('smtp');
$Email->emailFormat('html')
->template('myTemplate')
->to('someEmail#email.com')
->subject('someSubject')
->send('MyMessage');
unset($Email);
re-Instance cakeEmail
$arrEmails = array('email1#email.com','email2#email.com','email3#email.com','email4#email.com','email5#email.com');
$Email = new CakeEmail('smtp');
$Email->emailFormat('html')
->template('mySecondTemplate')
->to($arrEmails)
->subject('OtherSubject')
->send('MyOtherMessage');
I've also tried to create 2 different instances of cakeEmail but the same occur.
Else I've tried is to put in a loop "for" but nothing happens.
If anyone has an idea of what is happening here I would be very helpful and I appreciate it.
Thank you.
Take a look at the reset() method:
http://api20.cakephp.org/class/cake-email#method-CakeEmailreset
Related
I am not able to get access token from salesforce instance, Can anyone help me out from this.
I have tried many different ways, but not able to actually get it done :(.
HttpClient httpclient2 = new DefaultHttpClient();
HttpPost post = new HttpPost("https://instance.salesforce.com/services/oauth2/token");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("client_id", CONSUMER_KEY));
params.add(new BasicNameValuePair("client_secret", SECRET_KEY));
params.add(new BasicNameValuePair("grant_type", "password"));
params.add(new BasicNameValuePair("username", "emailaddress"));
params.add(new BasicNameValuePair("password", password+securityToken));
post.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpclient2.execute(post);
String body = EntityUtils.toString(response.getEntity());
System.out.println(body);
It is giving below error :
{"error":"invalid_grant","error_description":"authentication failure"}
Thanks in advance.
I believe that the problem is you need to use login.salesforce.com as the login host, not <instance>.salesforce.com but if that doesn't work, here is a complete example that uses httpclient to login and then make a query: https://github.com/jamesward/salesforce-rest-starter
It has over 2 days but Finally, I have done it :).
Program was correct but there was missing something with Configuration from Salesforce side. Below is the missing configuration which fixed my issue.
Thanks.
I am building a Laravel website where people can post tasks into a database. Currently, when I post tasks via my form, every account can see the data. How can I show data for only the specific person who posted it?
My blade file
My task controller file
Thank you very much in advance.
If your user has logged in the you can retrieve their id by Auth::user()->id;
In your index() method remove $tasks = Task::all(); and add
$userId = Auth::user()->id;
$tasks = Task::where('user_id',$userId)->get();
Hope this will help
i'm new to php and cakephp, i was following the Simple Authentication and Authorization Application tutorial from cakephp (http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html). All seem to working good.
I'm add a email confirmation to activate the account when a user subscribe. In the tutorial the password is using the blowfishpassword hasher. And i'm using it as a token in the link for the confirmation.
but i can't seem to be able to compare the link token with the password in the database...
$passwordHasher = new BlowfishPasswordHasher();
$motdepasse = $this->data['Utilisateur']['mot_passe'] = $passwordHasher->hash(
$this->data['Utilisateur']['mot_passe']
);
$link = array('controller'=>'utilisateurs','action'=>'activate',$this->Utilisateur->id
.'-'. $motdepasse);
public function activate($token) {
$token = explode('-',$token);
$user = $this->Utilisateur->find('first',array(
'conditions' => array('id' => $token[0],'Utilisateur.mot_passe' => Security::hash($token[1], 'blowfish', 'Utilisateur.mot_passe'))
));
debug($user);
debug($token[1]);
die();
}
Can you help me? thanks guys!
First of all you shouldn't send the password hash around, no matter how safe the hash possibly might be, confirmation tokens should be generated separately! Simply store it in an extra column or in a separate table.
That being said, in your activate() method you are hashing the hash again, which, in case the hash would actually be generated, would cause the comparison to fail. However the script won't genereate a hash, as you are using an invalid salt value which should result in the following warning:
Invalid salt: Utilisateur.mot_passe for blowfish Please visit http://www.php.net/crypt and read the appropriate section for building blowfish salts.
and Security::hash() will return an empty string. If you don't get such a message, then you'll need to enable the debug mode.
I'd suggest to get familiar with PHP, CakePHP, hashing and stuff first before you try to implement security related functionality!
You may want to check out https://github.com/CakeDC/users, it supports email verification and lot more out of the box.
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.
I am new to Resteasy, I am calling a service and getting the response successfully. I am able to print the response as well (which is the expected response).
ClientResponse<String> response= clientRequest.post(String.class);
System.out.println("response"+response.getEntity());
Console output is: response{"id":8,"displayName":"xyz_abc","roles":null, .....
But now I want to parse/map the response that I get from the service to a business object (like a User.java pojo) in client side application. I tried going through the docs but couldn't comprehend much. I tried googling, again not much help there. Please help me achieve this.
Thanks
Finally found the answer,
ClientResponse<String> response= clientRequest.post(String.class);
Gson gson = new Gson();
User user = gson.fromJson(response.getEntity(), User.class);
This solved my problem.