Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index()
- {
- /* connect to gmail */
- $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'febry.rizky@cbncloud.co.id';
- $password = '-------------';
- $inbox = imap_open($hostname, $username, $password) or die('Cannot connect: ' . imap_last_error());
- $emails = imap_search($inbox, 'ALL');
- if ($emails) {
- $output = '';
- $mails = array();
- rsort($emails);
- foreach ($emails as $email_number) {
- $header = imap_headerinfo($inbox, $email_number);
- $message = quoted_printable_decode (imap_fetchbody($inbox, $email_number, 1));
- $from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
- $toaddress = $header->toaddress;
- if(imap_search($inbox, 'ALL')){
- /*Store from and message body to database*/
- if(($from) == 'febririzki46@yahoo.com')
- {
- DB::table('email')->insert(['from'=>$from, 'body'=>$message]);
- }
- else
- {
- die();
- }
- //return view('emails.display');
- }
- else{
- $data = Email::all();
- //return view('emails.display',compact('data'));
- }
- }
- }
- imap_close($inbox);
- }
- public function showMail($id){
- // get the id
- $message = Email::findOrFail($id);
- $m = $message->body;
- // show the view and pass the nerd to it
- return view('emails.showmail',compact('m'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement