narendravaghela / cakephp-mailgun Goto Github PK
View Code? Open in Web Editor NEWMailgun plugin for CakePHP 3
Mailgun plugin for CakePHP 3
I've noticed that MailgunTransport.php uses "use Cake\Mailer\Email;"
If I'm not mistaken this namespace doesn't exist in versions prior to 3.1.
My app.php:
'EmailTransport' => [
...
'mailgun' => [
'className' => 'MailgunEmail.Mailgun',
'apiKey' => 'key-xxxxxxxxxxxxxxxxxxxxxxxxxxx',
'domain' => 'sandboxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mailgun.org'
]
],
'Email' => [
'mailgun' => [
'transport' => 'mailgun'
]
],
In my controller:
use Cake\Network\Email\Email;
` $email = new Email('mailgun');
$result = $email->from(['[email protected]' => 'Test'])
->to('[email protected]')
->subject('newsletter')
->template('send', 'send')
->viewVars(['news' => $news, 'newsletter' => $newsletter, 'newsDestaque' => $newsDestaque, 'imagemDestaque' => $imagemDestaque, 'domain_id' => $domain_id])
->emailFormat('both')
->addHeaders(['o:tag' => 'testing'])
->addHeaders(['o:deliverytime' => strtotime('+1 Min')])
->send();`
I am using this library with eu mailgun api. The problem is url is different than US. For now i edited the Mailgun.php $apiendpoint variable. It will be great to configure it from app.php.
We should update the plugin to support CakePHP 4.x
The MailgunTransport class is throwing deprecation errors about the use of the "config" method. Now, we have to use "setConfig/getConfig" instead.
I wonder if the $response->getStatusCode(); and/ or the use of $response->isOk(); could be added to the returned object. I realize that this might make the return from _sendEmail() a little different, but it would be nice to able to better manage errors.
Could not fetch https://api.github.com/repos/goetas/serializer/contents/composer.json?ref=813de268b702f501c873f90949495e497269b8ea, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+nikhil-ThinkPad-L460+2016-12-22+1329
to retrieve a token. It will be stored in "/home/nikhil/.composer/auth.json" for future use by Composer.
Token (hidden):
I'm writing a pull request to make this plugin pass on Cake 3.6.
When i updated the composer.json, the mailgun-php was updated to the version 2.5.
On their CHANGELOG, lots of things was changed.
The main problem is that after 2.1, their "/tests/" directory is not shipped by composer, so now this line fails:
https://github.com/narendravaghela/cakephp-mailgun/blob/master/src/Mailer/Transport/MailgunTransport.php#L22
So, i'll force the composer to stick on the mailgun-php 2.1, and leave the update to 2.5 for another pull-request.
@narendravaghela
I have configure cakephp mailgun as per your instructions. But it give me error as "Unknown email configuration "mailgun". "
Something is wrong with the namespace registry.
Following the doc step by step with cakephp 3.7
Instantiation fails.
$email = new MailgunEmail();
triggers:
Class 'App\Controller\MailgunEmail' not found
Hey
First off all, great plugin!
Is it possible that bcc doesn't work? Also, how do you add multiple contacts?
Best regards
Jordy
In Cake4, Mailer class clone transport before executing deliver method, then it restores the transport instance. When MailgunTransport is clone, the FormData instance in _formData property is shared between the two instances (original and clone) so even when _reset is called after sending email, the cloned instance keeps the previous _formData generating emails with multiple to
, subject
and from
headers.
Calling _reset
in new instance fixes the issue
Warning Error: fopen() expects parameter 1 to be a valid path, array given in [/home/mrogers/Dropbox/cakephp/webapp/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php, line 310]
2018-06-27 22:40:15 Warning: Warning (2): fopen() expects parameter 1 to be a valid path, array given in [/home/mrogers/Dropbox/cakephp/webapp/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php, line 310]
Trace:
Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 153
fopen - [internal], line ??
Mailgun\Connection\RestClient::prepareFile() - ROOT/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php, line 310
Mailgun\Connection\RestClient::post() - ROOT/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php, line 154
Mailgun\Mailgun::post() - ROOT/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php, line 204
Mailgun\Mailgun::sendMessage() - ROOT/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php, line 135
MailgunEmail\Mailer\Transport\MailgunTransport::_sendMessage() - ROOT/vendor/narendravaghela/cakephp-mailgun/src/Mailer/Transport/MailgunTransport.php, line 216
App\Mailer\Transport\MailgunTransport::send() - APP/Mailer/Transport/MailgunTransport.php, line 95
Cake\Mailer\Email::send() - CORE/src/Mailer/Email.php, line 2118
EmailQueue\Shell\SenderShell::main() - ROOT/plugins/EmailQueue/src/Shell/SenderShell.php, line 106
Cake\Console\Shell::runCommand() - CORE/src/Console/Shell.php, line 507
Cake\Console\CommandRunner::run() - CORE/src/Console/CommandRunner.php, line 141
[main] - ROOT/bin/cake.php, line 12
No issues with 1.0.5.
Your code is work on localhostbut serve side i am facing this issue Transport class "MailgunEmail.Mailgun" not found in cakephp 3.4
In CakePHP 3.7 the following deprecation warnings are emitted.
Deprecated Error: Response::json is deprecated. Use Response::getJson() instead. - /vendor/narendravaghela/cakephp-mailgun/src/Mailer/Transport/MailgunTransport.php, line: 362
I can submit a PR later this week on to fix this
Hi there, great job on this integration. I've one question, how do I set a domain dynamically? E.g. for some cases i use mg.domain1.com and some mg.domain2.com?
Attachements are added with local and remote path, but they dont get to mailgun.
When updating to version 4.0.0 and introducing the new MailgunEmail
class, I don't know if you can use it in Mailer
classes or you just have to use the default Email class.
It would be useful to use the MailgunEmail
class methods inside Mailer
configuration, like enableDkim
, setTags
and so.
On cake, we use
$email->setAttachments([
'logo.png' => [
'file' => WWW_ROOT . Configure::read('App.imageBaseUrl') . 'logo.png',
'contentId' => 'logo'
]
])
But on the mailgun-php is
$mg->message()->send('example.com', [
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'Test inline attachments',
'text' => 'Test',
'inline' => [
['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg']
]
]);
So, is it possible to send inline attachments with this plugin?
Hi,
I'm having an issue that is driving me nuts right now.
My CakePHP version is 3.8.1 and I have this plugin installed with the transport and profile properly configured and working.
When I deploy my application in any server everything works like charm. The Mailgun responds very quickly and I don't have any kind of problem.
The issue comes when I run my app in my local machine (where I develop everything so is slowing me down a lot). I have a Mac Os Mojave laptop with LAMP stack installed via Homebrew. I've tried with different PHP versions (5.6, 7.0, 7.1, 7.2 and 7.3)
When I try to send a message via Mailgun I always get this timeout error. I'm connected to my company network.
I can't figure out why this error appears since I have my local machine configured as a standard web server with a LAMP stack.
The funny thing comes when I try to change my network connection. If I share internet from my mobile phone or work at home I don't get any timeout and everything works as expected.
For further information, if I try to run the standard PHP code showed in the Mailgun Docs or use Postman to replicate any API call it works in every network.
Any help would be useful. Thank you in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.