sending mail with attachement using Amazon SDK php - amazon-web-services

Anyone does know if it's possible to send attachments with the method sendEmail without build the message manually?
actually i send this parameters, but I find no docs for attachs files:
$message = array(
'Source' => $this->sender,
'Destination' => array(
'ToAddresses' => [$this->to],
),
'Message' => array(
'Subject' => array(
'Data' => $this->subject,
'Charset' => 'utf-8',
),
'Body' => array(
'Text' => array(
'Data' => $this->bodytext,
'Charset' => 'utf-8',
),
'Html' => array(
// Data is required
'Data' => $this->bodyhtml,
'Charset' => 'utf-8',
),
),
),
);

Finally the best easy way to send attach files it's use phpmailer to compose the body including the attach files and send it in Amazon through the .SendRawEmail method

Related

Query string in drupal service custom resources

I am trying to use query string structure in drupal services API. it's not working for me.
I have also search most of the solutions, but all failed.
here is m drupal code:
function rapid_services_resources() {
$resources = array(
'get_data' => array(
'operations' => array(
'retrieve' => array(
'help' => t('Gets user email of uid passed.'),
'callback' => 'my_module_get_user_email',
'args' => array(
array(
'name' => 'nid',
'type' => 'int',
'description' => 'The display ID of the view to get.',
'source' => array('param' => 'nid'),
'optional' => TRUE,
'default value' => 'default',
),
),
'access arguments' => '_blog_access_provide_access',
'access callback' => '_blog_access_provide_access',
//~ 'access arguments append' => FALSE,
),
),
),
);
return $resources;
}
function _blog_access_provide_access() {
return TRUE;
}
function my_module_get_user_email($nid){
var_dump($args);die;
}
I want url like this.:
http://localhost/drupaltest/rapidapi/get_data/?nid=111
Please let me know where i did wrong.
thanks in advance.
Hi here are to reference that will be useful
http://pingv.com/blog/an-introduction-drupal-7-restful-services
https://www.drupal.org/node/783460
Also I am not sure about the query string, but for the retrieve operation you can set it as part of the url
ex:
http://localhost/drupaltest/rapidapi/get_data/<nid should be here>
http://localhost/drupaltest/rapidapi/get_data/111
Also using the source path as source
'source' => array('path' => '0'),
I would think that source param only works for an index operation and not retrieve

Compare user ID exactly, not with LIKE

I have this query -
<?php
$post_args = array(
'post_type' => 'tribe_events',
'eventDisplay'=>'custom',
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'compliance',
),
),
'meta_query' => array(
array(
'key' => 'associated_people',
'value' => $current_user,
'compare' => 'LIKE'
)
)
); ?>
At the moment it is fetching events that are associated to a particular person in a custom post type called people. I'm doing this using a relationship advanced custom field called associated_people.
I'm using the 'compare' => 'LIKE' code to do this also, but it's fetching other id's that are like the current one. e.g. If it's looking for ID 117, it's also bringing back 17, 11, 7..etc.
Is there a way to look at just the exact ID?
So far we have tried changing it to 'compare' => '='
Any help would be much appreciated. Thanks!
We solved it by changing the way the value was called -
<?php
$post_args = array(
'post_type' => 'tribe_events',
'eventDisplay'=>'custom',
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'compliance',
),
),
'meta_query' => array(
array(
'key' => 'associated_people',
'value' => '"' . $current_user . '"',
'compare' => 'LIKE'
)
)
); ?>

zendframework 2 table gateway And doctrine 2- is it possible to operate both systems at same time

i am using Zendframework 2 . i wonder if it possible to use both table gateway and doctrine 2 in the same application.
below is my configuration. i tried to run it but i noticed that the speed of my application slowed down considrable.
i was wondering if this was beucase there is a conflict between both applications or because i have not configured it properly.
global PHP file
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=thetable;host=localhost',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter'
=> 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);
local php
return array(
'db' => array(
'username' => 'user',
'password' => 'password',
),
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'user',
'password' => 'password',
'dbname' => 'thetable'
)
)
)
),
);

ZF2 form validation not working properly for email

i have a input box with type="email" and validation it with zend validator
<input type="email" name="email" > email </input>
'email' => array(
'required' => true,
'validators' => array(
array(
'name' => 'Regex',
'options' => array(
'pattern'=>'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+#[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/',
'messages' => array(
\Zend\Validator\Regex::NOT_MATCH=>'Please fill correct email ',
)
),
'break_chain_on_failure' => true
),
),
problem is if i use another array to check for
IS_EMPTY
zend regex again does not display the above error instead display default zend regex error and if i remove IS_EMPTY then it works fine. regex error is
1. input does not match to expression '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+#[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/'
EXACTLY NOT ABLE TO UNDERSTAND WHY THIS WORKS FINE WITHOUT EMPTY CHECK AND DOESN'T WORK ALONG WITH IT
You don't need to use notEmpty, you only need to set the field as "required" and specify the error message:
$this->add(array(
'name' => 'email',
'required' => true,
'error_message' => 'Please entry e-mail.',
'validators' => array(
array(
'name' => 'EmailAddress',
'options' => array (
'messages' => array(EmailAddress::INVALID => 'Please specify a valid e-mail.'),
),
'break_chain_on_failure' => true,
),
),
));
I have also the same dilemma where this "input does not match to expression" always appears instead of the message for EmailAddress::INVALID_FORMAT. But I found that the code you posted fixed the same error I had. This is my code.
'validators' => array(
array (
'name' => 'Regex',
'options' => array(
'pattern'=>'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+#[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/',
'messages' => array(
Regex::NOT_MATCH => 'Please provide a valid email address.',
),
),
'break_chain_on_failure' => true
),
array(
'name' => 'EmailAddress',
'options' => array(
'messages' => array(
EmailAddress::INVALID_FORMAT => 'Please provide a valid email address.',
EmailAddress::DOT_ATOM => '',
EmailAddress::INVALID_FORMAT => '',
EmailAddress::INVALID_LOCAL_PART => '',
EmailAddress::QUOTED_STRING => '',
)
),
),
),

ZF2 + Doctrine 2 : Cli Tool has Access Denied

I have a ZF2 2.1.3 app with Doctrine 2.
I installed using composer:
"zendframework/zendframework": "2.*"
,"doctrine/doctrine-orm-module": "dev-master"
A create a file config/autoload/database.local.php with the following:
return array(
'doctrine' => array(
'connection' => array(
// Default connection name
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'dbname' => 'zf2-experimental',
'user' => 'root',
'password' => '',
),
),
),
),
);
I create my entity Bar under Foo module (src/Business/Entity/Bar.php) and configure it on module.config.php like this:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Business/Entity'),
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Business\Entity' => __NAMESPACE__ . '_driver',
),
),
),
),
Ok! It's exactly at Sam says here!
Then I create a simple Foo entity and run the doctrine cli tool:
c:\wamp\www\zf2-Experimental>.\vendor\bin\doctrine-module.bat orm:validate-schema
[Mapping] OK - The mapping files are correct.
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'username'#'localhost' (using password: YES)
orm:validate-schema
c:\wamp\www\zf2-Experimental>
Looks like the cli tool can get my connection parameters in my config/autoload/database.local.php!
On Application index I tested my config:
$config = $this->getServiceLocator()->get('config');
\Zend\Debug\Debug::dump($config['doctrine']['connection']['orm_default']);
And this returned:
array (size=4)
'configuration' => string 'orm_default' (length=11)
'eventmanager' => string 'orm_default' (length=11)
'params' =>
array (size=5)
'host' => string 'localhost' (length=9)
'port' => string '3306' (length=4)
'user' => string 'root' (length=4)
'password' => string '' (length=0)
'dbname' => string 'zf2-experimental' (length=16)
'driverClass' => string 'Doctrine\DBAL\Driver\PDOMySql\Driver' (length=36)
Someone can, please, help me?! :)
Thanks you all!
Well, I waste a lot of time trying to solve this and finally did.
I forgot to mention that I using ZF1 environment-specific configurations style!
You can see here!
I create my database config file in the following structure (I didn't mention this before, because I thought It wouldn't interfere on the question):
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
// Here! My config path is config/autoload/app_env/development/
'config/autoload/app_env/' . (getenv('APPLICATION_ENV') ?: 'production') . '{,*.}.local.php',
),
So, my database configs actually are in config/autoload/app_env/development/database.local.php!
When I copy-paste the file to config/autoload/database.local.php my CLI Tool works!
But WHY? Why the Cli Tool can't look for the config file inside another directory?
There is a way to work with sub-folders?
Thanks for the help!