Laravel Mailgun tracking emails - php

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!

Related

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

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

How send Email from server email in laravel 5.3

I am new laravel and i just made a small project of article posting and on user registration i just want to send successfully register email to user email. I searched every where in all tutorials they are giving demo for send mail from gmail and some another email providers. I just want to know is it possible to send the mail simply from server email id ? like cordignator framework:
$this->email->to('rahul#gmail.com')
$this->email->subject('Testing Email')
$this->email->message('hello')
$this->email->send()
set your server mail details in .env file then
run a command php artisan publish
send mail like Mail::to($user)->send(new UserRegister());
and your UserRegister class in app/Mail have one method
public function build()
{
return $this->subject("Welcome to My site")
->view('`vendor.notifications.register`',compact(''));
}
And You can set all message body in resourse/view/vendor/notifications/register
see more on laravel mail

How to change header information of mail in Laravel?

I am creating a simple contact us form using Laravel 5.1
public function sendMessage(){
$data = [
'name' => Input::get('name'),
'email' => Input::get('email'),
'subject' => Input::get('subject'),
'body' => Input::get('body')
];
Mail::send('emails.contact',$data, function($message) use($data){
$message->from($data['email'], $data['name']);
$message->to('smartrahat#gmail.com','Mohammed');
$message->subject($data['subject']);
});
Session::flash('success_message','Mail sent successfully!');
return redirect('contact');
}
Everything is working fine but the sender email address is not the one it get from the contact page. The email is sent from the address which I configure in .env
I want to have the email from the sender email address which he filled up contact form. Or, you can say I want to change the header information (only from, I can change other information).
Well Laravel will send the mail through the given smtp server. I guess the smtp server (e.g. google doing this) will not let you change your from address to another address then the account belongs to.
If you want to reply to this address directly in your email programm you can add $message->replyTo($data['email'], $data['name']);.
The $message variable inside the Mail::send() function is a SwiftMailer message instance. Therefore, you can work with headers just like the SwiftMailer documentation shows. Just use $message->getSwiftMessage() to get and manipulate the headers.
Also, you absolutely can change the From header, but if you change it to a different domain, you'll have to deal with phishing warnings in the client. You can resolve that by setting up DKIM and SPF records, and you will need to have access to the DNS settings for the domain to do that.

How to send multiple messages in Zen-Cart using zen_mail?

I'm trying to invoke zen_mail twice so that I can send an email to myself (admin) and my customer. I'm using the following to invoke it but I cannot seem to get it to work. When I do call it, it causes the emails not to send out. Can anyone help?
zen_mail($customer['customers_firstname'] . " " . $customer['customers_lastname'],
$admin,
$subject,
$text,
TITLE,
$admin['admin_email'],
$block,
$module_used
);
You can send messages to multiple recipients using zen_mail but the syntax is screwy. Why not just call zen_mail twice - once for the customer and once for the admin. This is the technique that is used in
includes/classes/orders.php
you can search for zen_mail in this file and find the calls.
In the ZENCART admin:
Configuration->Email Options:
Send Copy of Order Confirmation Emails To:
Here you can place multiple email addresses: ME,Joe,Fred
This will send confirmation emails to ME, Joe and Fred in addition to your customer.

Sending an html email with phpmailer and codeigniter

I am sending emails with phpmailer package and using the package with codeigniter framework. I have made a helper function out of the phpmailer package which takes arguments as sender's address, recipient's address, subject and message body. Everything goes fine and the message is delivered to the inbox.
My problem is I have a large body which can be a seperate html file. For this I have created a view and I am trying to send the argument $this->load->view('viewname'); through the helper function in my controller. But instead of displaying the body in mail I get the file displayed on my final view page and the mail body goes blank. Any idea how I can achieve
Using $this->load->view('viewname'); without any additional parameters will output the view. What you need is to set the third parameter to TRUE as suggested in the Returning views as data of the CodeIgniter User Guide's View documentation.
Example:
$string = $this->load->view('viewname', '', true);

Categories