Drupal 6 Mimemail with attachment - drupal

Can anyone help me with drupal mimemail for attachment i am using below mentioned code to send attachment file on specific email, but somehow its not working, kinldy help me thanks in advance
$body = "test body with attachments";
$subject = "My test message";
$attachments[]=array(
'filepath' => file_directory_path().'/document.pdf',
'filename' => 'wonderful.pdf',
'filemime' => 'application/pdf',
);
mimemail("xxxxx#gmail.com", "xxxxxx2#gmail.com", $subject, $body, NULL, array(), NULL, $attachments,'');

I'm doing something very similar. My code is basically:
$message['attachments'][] = array(
'filepath' => $zipfilepath,
'filename' => 'my-attachment.zip',
'filemime' => 'application/zip',
);
from within my hook_mail module callback. See http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_mail/6
Are you sure that you've done the following:
enabled "mimemail" module;
checked the option in admin to "Use mime mail for all messages";
selected "mimemail" as the "E-mail Engine" (at the bottom of the admin page).
Mine is working just fine. I have SMTP module installed as well, and it works with either module selected as the Email Engine.

Related

How to use file upload option in WooCommerce payment gateway admin options?

I am developing a plugin to integrate a payment gateway in WooCommerce. I have done one before.
But in this one, I need to upload a key file in gateway settings and that is used to hash the data before making payment request to related portal.
I have following code which allows to choose file, but I doubt this is working in the back end.
'sandbox_pvt_key' => array(
'title' => __( 'Test Private Key', 'woocommerce-custom-gateway' ),
'type' => 'file',
'desc_tip' => true,
'description' => __( 'Please upload the test private key file; this is needed in order to test payment.', 'woocommerce-custom-gateway' ),
'default' => '',
),
The output looks like the following:
Can anybody lemme know if this is supported option in the gateway settings? If not, can anybody guide me on how I can customize it via some hook/filters or any other way.
This can be achieved in the process_admin_options()
public function process_admin_options() {
$this->upload_key_files();
$saved = parent::process_admin_options();
return $saved;
}
private function upload_key_files() {
//handle uploads here
}

Handle incoming Array from Guzzle

So i have been trying to get guzzle working, i can send a post request which sends some kind of array and I would like to know, how can i receive it at an endpoint? i can handle things like if(isset($_POST['nameHere'])) but not the array thingy
$client = new Client();
$response = $client->request('POST', 'http://httpbin.org/post', [
'form_params' => [
'email' => 'test#gmail.com',
'name' => 'Test user',
'password' => 'testpassword',
],
'debug' => true
]);
echo '<pre>' . print_r((string)$response->getBody(), true) . '</pre>';
}
ps: My custom laravel application is the sender, my wordpress site is the receiver.
Got it working, i was missing the .php ending in my url, because i chose not to test with httpbin but directly with my api.
and in wordpress i dont get anything because this is the sendercode i published not the receiver (wordpress). i wouldnt know how to test it. thanks anyway

Why xmlrpc wordpress do not work in some live site but in some it is working.

I am trying to post to site 2 (demo.com) from site 1 (test.com) using code below. it is not working.
But when i try to post from localhost to site 1(demo.com) with same code it works.
I do not know what is the problem. Please help me. Thank you
$client = new IXR_Client("http://demo.com/xmlrpc.php");
$postcontent = array(
'post_type' => 'post',
'post_title' => 'wwww',
'post_name' => 'wwww',
'post_content' => 'wwww'
);
$res = $client -> query('wp.newPost',1, "username", "password", $postcontent);
$postID = $client->getResponse();
Most likely the wordpress server you are trying to post to has IP based whitelisting or blacklisting enabled.
.htaccess file on the server would have the rules for the same.
The server has to allow xmlrpc.php file for your client.

Facebook Posting using FB API phpSDK

i created my app on fb with permissions ready to publish on users behalf, the thing is, a regular post has Like and Comment links, like buttons on bottom of the post, i want to add my custom link : VOTE NOW, its a poll post
how can i do that?
someone gave an answer but for js sdk not php, n i cant find it on facebook dev documentation
some gave a close enough solution, but ddnt seem to work on php with modifications
FB.ui({
method: "feed",
link: "LINK_URL",
...
actions: [
{ name: "Read Now", link: "URL TO THE READ NOW " }
]
}, function(response) { console.log(response); });
It seems it's working with /me/feed but with my custom /me/xxxxxx:submitted_a_poll/ its not working
When you make a call with the PHP SDK, you also pass a similar set of parameters:
$attachment = array(
'link' => 'http://your-cool-site.com',
'description' => 'This is the description',
...
'actions' => array(
array(
'name' => 'Vote Now!',
'link' => 'http://your-cool-site.com/vote.php'
)
)
);
$result = $facebook->api('/me/feed/', 'post', $attachment);
All you really have to do is add the relevant action settings to your parameters.

Edit mail.inc to enable SMTP server for sending mail

i want to place the following codes into include/mail.inc of Drupal7 so that i can send mail from SourceForge's project web space. Don't ask me to install SMTP Authentication Support, and i don't have access to php.ini , I wonder where should these codes be placed? Thanks in advance!
include('Mail.php');
$recipients = array( 'someone#example.com' ); # Can be one or more emails
$headers = array (
'From' => 'someone#example.com',
'To' => join(', ', $recipients),
'Subject' => 'Testing email from project web',
);
$body = "This was sent via php from project web!\n";
$mail_object =& Mail::factory('smtp',
array(
'host' => 'prwebmail',
'auth' => true,
'username' => 'YOUR_PROJECT_NAME',
'password' => 'PASSWORD', # As set on your project's config page
#'debug' => true, # uncomment to enable debugging
));
$mail_object->send($recipients, $headers, $body);
if this code could success send email without drupal7 (you must make sure it)
then you could do it in three ways:
write a drupal 7 module ,copy mail.php into *.module, and make the rest code as a function,that's the way as the handbook of drupal.
just copy all of the code to you theme/page.tpl.php , and run it directly , a little dirty
hack drupal core , include/mail.inc , just change function drupal_mail_send

Resources