PHP code to Read Sent Items from an Email Account - php

I need to read sent items from an email account to insert the details into a database as part of development of a support ticket system.
I have managed to implement reading inbox emails using the below code and successfully inserted those into the database.
$stream = #imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);
$overview = imap_fetch_overview($stream,$email_id,0);
$message = imap_fetchbody($stream,$email_id, 1.2);
I have searched all over the internet and stackoverflow to find a solution, but no use. I haven't found even a single discussion regarding this (Reading sent items from an email account).
Hope someone here can help me in this issue by sharing some useful code snippets or URLs for reference.
Thanks in advance.

Got it working and successfully retrieved all sent emails by replacing {mail.domain.com:143/notls} with {mail.domain.com:143/notls}INBOX.Sent.
That is by setting the value of $current_mailbox['mailbox'] to {mail.remanns.com:143/notls}INBOX.Sent
The complete code is
$mailboxes = array(
array(
'label' => 'domain.com',
'enable' => true,
'mailbox' => '{mail.domain.com:143/notls}INBOX.Sent',
'username' => 'mail#domain.com',
'password' => 'mypassword'
)
);
$stream = #imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);
Thank you Darren for guiding me through the right path. I figured it out by following you suggestion regarding finding the sent box name first.

Related

Mandrill text field character limit PHP

I am trying to send a simple email using Mandrill and everything works well until I put too much text into the text field, here is what I mean:
$message = array(
'subject' => $subject,
'text' => $content,
'from_email' => 'myemail#gmail.com',
'to' => array(
array(
'email' => $toMail,
)
)
);
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
So when $content contains more than about 1000 characters the email does not send and I get a 500 error, which seems to be an API timeout. However I need to send emails with up to 20000 characters in them. Has this happened to anyone? Also this worked a couple months ago for me, I am not sure why it does not work anymore.
I saw that SMTP headers can only be 1000 characters long, but the text segment doesn't land in the header does it?
UPDATE: So interestingly enough, it still works fine on my main computer. I moved the website to another machine running ubuntu 14.04 and that is where the error started appearing. Anybody have any ideas as to why?

ALL GCM parameters?

i´ve written a "pushserver" for my app via PHP.
The push notifications i´ve sent via PHP are all received on the device, so far.
But, i can just send/set the "message" and "title", see:
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
'message' => $message,
'title' => 'My App',
'vibrate' => 1,
'sound' => 1,
'icon' => "http://example.com/image.jpg",
"style" => "inbox"
),
);
"icon" and "style" are not working (vibrate and sound not tested, yet).
Every link for the parameters i´ve found is broken or kind of "you need to do object.setSomething() in JAVA.
Is there a list anywhere where i can see ALL parameters, which i can send to GCM? No matter, what language i use?
Cheers,
Chris
couple of things need to keep in mind while all the data which you sending from server end
Is there a list anywhere where i can see ALL parameters,
exp :- you can send as many parameters as you want but offcourse there is limitation but not key specific just like you can use "textmessage" instead of "message" but make sure to retrieve the value from same key which you are assigning from server end
1) please make sure that you are getting all the data in gcmintentservice class try to print the log of all intent data.
please remember that this is just a string data it is not going to download the image for you. you have to download using volley library or any suitable library

Mailgun configure for PHP

I'm new on mailgun, there i found php code but unable to understand all for this asking help on here. please help me anyone.
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mgClient = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$domain = "samples.mailgun.org";
$result = $mgClient->sendMessage("$domain",
array('from' => 'Excited User <excited#samples.mailgun.org>',
'to' => 'Mailgun Devs <devs#mailgun.net>',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomeness!'));
But where i find autoload.php. please help me anyone. also their girhub project showing error.
Thanks in advance.
If you go here, you will find all instructions for sending email through MailGun.
Click on Library download to download all the MailGun files with the Composer.
Then you just have to place the autoload.php correctly in your Mailgun folder to match with your code, and it'll work like a charm.
Note that the Mailgun's response is in JSON, use
echo "<pre>";
print_r($results);
echo "</pre>";
to print your results in an array way. It's easier to read and to analyse.

opauth linkedin email

I'm working on some code and trying to get the email address from linkedin. I have looked at there docs to confirm that they do support sending the email via api now.
I tried to add 'scope' => r_emailaddress. If I look in the raw section of the response I see email-address but this does not seem to be getting added ['auth']['info'] array as email so I have no standerdized way of always getting an email from all of my various providers.
I have also tried the following with out success.
$this->mapProfile($profile, 'email', 'info.email-address');
$this->mapProfile($profile, 'email', 'email-address');
Any thoughts?
http://opauth.org/
It ended up being this.
$this->mapProfile($profile, 'email-address', 'info.email');
You also need to add this to linkedinstrategy.php $defaults variable
'scope' => 'r_emailaddress'

hotmail: user authentication and contact retrieval with PHP

I am trying to write a PHP script that will allow me to do two things:
Allow users to use their Hotmail (I think its called 'Live' now?) account to authenticate themselves to a website
Retrieve an authenticated users contact list from Hotmail.
I have trawled the internet for the past 6 hours, looking for at least a working example that I can modify/extend to do the above two things. There are several dozens similar questions asked here on SO for example - NONE of the proffered answers work any more (admittedly, some of the questions were a few years old).
I tried the Microsoft site and downloaded the latest version of their API which seems to evolve at a rather alarming rate. I finally managed to track down an API which has not been deprecated (yet?).
I followed the instructions and when I attempted to authenticate, I was rewarded with the following mesage, for my efforts:
We're unable to complete your request
Windows Live ID is experiencing technical difficulties. Please try again later.
I immediately tried the online version of the demo and perhaps unsurprisingly, that worked like a charm.
As an aside, I managed to implement the same functionality for Yahoo and GMail, using their OPEN APIs, under an hour each. Now, it is possible that my unmitigated hatred of all things proprietary (sorry make that Microsoft), is causing me to lose the plot a little here.
Has anyone ACTUALLY (in 2012) managed to get a working sample in PHP that allows:
Hotmail (live?) user authentication
Hotmail user contact email retrieval
If you have, a code snippet, or a link to where I can find such a snippet would be very useful, as I have so far, wasted a whole afternoon trying to work the Microsoft Live API via PHP.
PS: No, I'm not interested in OpenInviter, its broken.
i wrote my own oauth library based around a single array for each service provider. this array contains all of the data required to perform authentication and retrieve user data. the array i use for msdn (ie. hotmail, outlook, xbox, msn) is:
$msdn = array
(
'oauth_version' => '2',
'oauth_method' => 'GET',
'redirect_user_params' => array
(
'url' => 'https://oauth.live.com/authorize',
'response_type' => 'code',
'http_params' => array
(
'url',
'client_id',
'redirect_uri',
'response_type',
'scope',
'state'
)
),
'obtain_access_token_params' => array
(
'url' => 'https://oauth.live.com/token',
'grant_type' => 'authorization_code',
'http_params' => array
(
'url',
'client_id',
'client_secret',
'code',
'grant_type',
'redirect_uri',
'scope'
)
),
'scope' => 'wl.signin wl.basic',
'obtain_user_data_params' => array
(
'url' => 'https://apis.live.net/v5.0/me',
'http_params' => array
(
'url',
'access_token',
'scope'
)
),
'client_id' => 'xxxxx', // = oauth_consumer_key in oauth 1.0 lingo
'client_secret' => 'xxxxxxxxxxxxxxx',
'readme_url' => 'http://msdn.microsoft.com/en-us/library/live/hh243647.aspx'
);
the parameters for each of the three oauth stages (ie "redirect user", "obtain access token" and "obtain user data") are in the http_params arrays. in the case of msdn these parameters end up in the query query string of the url that i send out with curl (since msdn only accepts GET, not POST).
i haven't tried retrieving the user's contact address book, but this would just be a case of extending the scope element with whatever extra information you require (documented here http://msdn.microsoft.com/en-us/library/live/hh243646.aspx). as you can see from the http_params arrays, the scope parameter is used in each of the three oauth stages.
Try out a Hotmail/MSN/Live import on the CloudSponge test drive to see if that's the user experience you're hoping for.
If it works for you, you can use our widget or our API. If you want to use the API, we have a PHP wrapper already written for your convenience.
Please confirm your callback url is with http:// if you only put www.domain.com then get this issue..

Categories