IMAP library : get all emails from outlook email account with lumen - php

I am using below library ,
"php-imap/php-imap": "^3.0"
I want to get all the emails from email account , I am using below method,
$mailboxs = new \PhpImap\Mailbox('{imap-mail.outlook.com:993/imap/ssl}',
"outlook_email_account",
"outlook_email_password",
"attachment"
);
$mailsIds = $mailboxs->searchMailbox('ALL');
It gives me few mails ids , I want to get all ids of all emails of outlook account.Is it possible.I also want to know the mailbox name of emails.
Please can you tell me which method I can use to get all emails

Related

Laravel Mailgun tracking emails

I'm trying to track emails sent via laravel mailgun driver. I want to be able to view the emails in the 'analytics' page of app.mailgun.com.
I am able to send emails using Postman with the following headers: o:tag o:tracking o:tracking-clicks o:tracking-opens and these seem to work fine. I can see these in the 'analytics' page. I have also successfully set up web hooks so I can track individual events for each email.
According to the documentation if I am sending via SMTP I need to send these tags: X-Mailgun-Track: yes, X-Mailgun-Track-Opens = yes. I have set these using the following code in the build method of my mailable class:
$this->withSwiftMessage(function ($message) {
$message->getHeaders()->addTextHeader(
'X-Mailgun-Track', 'yes'
);
$message->getHeaders()->addTextHeader(
'X-Mailgun-Track-Opens', 'yes'
);
});
I can see these headers are added when I open the email in a text editor. The email does not show up in the mailgun 'analytics' page.
Any help on this would be appreciated. Thanks!

Sending Emails to Many Recipients in The 1000's Using Laravel and Mailgun

I am using Laravel 5.5 and Mailgun. I want to send email campaigns to over 700 recipients and likely this list will grow into the thousands. Currently I am looping through each email address and sending the emails one at a time. As a result usually only about 530 emails go out. I have searched the net and cannot seem to find a good explanation on how to approach this in a more efficient way so that all the emails are sent. Any suggestions would be greatly appreciated.
public function mailCampaign()
{
//Code to get all email data in JSON
$emails= json_decode($data->getBody());
$baseUrl = config('constants.base_url');
foreach($emails as $key => $email){
Mail::to($email)
->send(new EmailInstance($variable, $email, $baseUrl));
}
$data = ['message' => 'Success. Emails have been sent.'];
return response()->view('emails.mail', $data, 200);
}
You shouldn't send emails one by one. Use Mailgun API instead. You can send thousands of emails using API with Bogardo/Mailgun package.
Mailgun supports the ability send to a group of recipients through a single API call. This is achieved by specifying multiple recipient email addresses as to parameters and using Recipient Variables.

Sending email with signature using Gmail API

I got the Gmail Rest API sending part working but the e-mail doesn't include the signature and in recipient's inbox the 'from' label is sender's user id not the name of the user.
This is in php.
$mime = new Mail_mime();
$mime->setFrom("ABCD"); //This doesn't work....
$mime->setSubject('Testing');
$mime->setTXTBody('This is a demo mail');
$mime->addTo('a#a.com');
$message_body = $mime->getMessage();
$encodeMessage = base64url_encode($message_body);
$message = new Google_Service_Gmail_Message();
$message->setRaw($encodeMessage);
$send = $service->users_messages->send('me', $message);
Is there anyway to include the signature and change the 'from'?
The signature is not added by the API because it is a setting on the web client, not a global setting for the entire account. If you configure your Gmail account on Thunderbird, Outlook or another email client, Gmail will not add the signature either. You should think about Gmail in two separate ways:
The web client interface, accessible at https://mail.google.com, which is just an email client like any other;
Your inbox, the place where messages end up in, which is completely independent of the clients you use to access it.
In other words, this is an email client-dependent setting, and the only thing the clients do is add a bit of text to the text you write yourself, nothing else.
I know this is old but you can retrieve via API the users signature.
https://developers.google.com/admin-sdk/email-settings/#manage_signature_settings
you can then append to your email that you are composing.

Class MailerPHP strange behaviour (looping array of address)

I am using Class MailerPHP to send emails on the website. Actually is working perfect as it have to work but there is some strange stuff that i can not figure out why is like this.
1. I have an array of address that i am sending emails, the array is like this:
$email = new sendEmail();
$_ADMIN_EMAIL = array('first_email', 'second_email', 'third_email');
$email->setEmail($_ADMIN_EMAIL);
The problem is when is sending emails, is sending 3 emails:
1. sending to first_email
2. after sending to first_email and second_email
3. and at the end sending to first_email, second_email and third_email
I would like to send only one to all 3 and do not send 3 times email, i do not understand why is sending like this.
2. And second problem is i am using my Google account to connect to the SMTP to send emails, and i do not know why in the TO field of the email is showing my gmail address that i connect to the SMTP, i setup which address to show there and is showing + my gmail account:
I have this configuration only and i didn't put anywhere else my gmail account only for SMTP connection:
public $Username = 'my_gmail_account_to connect_to_smtp';
public $Password = 'my_gmail_account_password';
The result of this when i get emails is first email that i setup to show for reply + my_gmail_account_to connect_to_smtp, i need to take out my_gmail_account_to connect_to_smtp from the email that the user will not see it.
If you need for information about the code i use please let me know i will put.
All the code that i send email:
$_ADMIN_EMAIL = array("first_email", "second_email", "third_email");
$email2 = new sendEmail();
$email2->setSubject("Subject");
$email2->setUserName($_USER['name']);
$email2->setMT4Account($_USER['login']);
$email2->setDate($_USER['date']);
$email2->setAmount($_USER['amount']);
$email2->setCurrency($_USER['currency']);
$email2->setRegisteredBankAccount($_USER['type']);
$email2->setBankAccountName($_USER['card']);
$email2->setTemplate('template_for_the_email');
$email2->setEmail($_ADMIN_EMAIL);
echo $email2->send();
Try this:
$_ADMIN_EMAIL = array('first_email', 'second_email', 'third_email');
foreach($_ADMIN_EMAIL as $ademail)
{
$email->setEmail($ademail);
}

imap_search return blank result

I have a gmail account; Three other emails are related to this one.
When I receive an email at xxx#mydomain.com it will be transferred to xxx#gmail.com.
Also when I send a message I can use an alias which mean that using gmail I send a mail with my xxx#mydomain.com.
When I use imap_search, From xxx#mydomain.com or To xxx#mydomain.com the result is blank but messages exist in my Inbox. Is this a problem of imap_search?
The solution is:
The default folder when we make imap_connection is INBOX. When we try to make imap_sort or iamp_search. We don't get anyresult. We have to switch to the folder which contain all messages for example [GMAIl]/All.

Categories