I've read an article from the Symfony2 Cookbook, called "How to work with emails during development", specifically "Viewing from the web debug toolbar". It said that if an email is send and request than redirected, you can still view sent email with 'intercept_redirect' option. However, there is no information regarding how to view an email that was sent with AJAX request...
I believe that such function was implemented in 2.6, according to this article. But most of my project using 2.3, and currently I'm using dirty things like dumping content in response to view it on Network tab in browser toolbar, but that's quite bad for testing purposes.
I've read solutions like this one, but there is still no info about emails.
Maybe anyone had a similar issue? Thanks in advance.
The only thing you actually need is having access to debug tokens for your AJAX requests, so you could then open up the profiler and look at the mailer stats. The easiest way to do this would be:
$(document).ajaxComplete(function(event, XMLHttpRequest, ajaxOption) {
if (XMLHttpRequest.getResponseHeader('x-debug-token-link')) {
// This is the link to debug panel
console.log(XMLHttpRequest.getResponseHeader('x-debug-token-link'));
}
});
This would log all the profiler links to the console. So, after an XMLHttpRequest has completed you could open them up and see whether your emails were sent.
Related
Hi to any PHPMailer expert.
Being using the mailer and works like a charm!
I have received mails several from various organizations and I get a "View in Browser" option.
I would like to add that same functionality to my mails. I have googled endlessly without success :(
Can anyone point me in the write direction or post the code?
As per usual your help is always appreciated.
Many thanks
Barry
I'm not aware of anything specific to Outlook for doing this, but the normal approach to this (what I do) is to make the same message available as a web page as part of your sending process. On my own system it uses exactly the same mechanism that's used to preview mailings before sending.
So when you have some HTML that you use to generate your email message, do the same thing but render it as a web page directly. If you're using PHPMailer you would do whatever you normally do to build a message and put your content in the Body property and send it, but just output it to the browser instead.
I cant track down the event in the framework, which is logging mails sent (via mailgun api). It is dumping raw attachment data (in my case, pdf splurge) into the log - and I want to stop this!
I have found what looks like the the event and it being fired
vendor\laravel\framework\src\Illuminate\Mail\Events\MessageSending.php
But cant see where it actually does anything!
Is this possible to either disable logs? Or stop it logging attachment data
Thanks
I have a little issue with a application wich is specified the following:
I need to send to a credit card payment webservice some data by post, so the webservice will proccess the information and return a XML.
I thought I could do it with the $.post() jQuery Ajax method.
That's my code:
$.post("https://comercio.locaweb.com.br/comercio.comp", {
identificacao: dadosPagamento[0],
modulo: dadosPagamento[1],
operacao: dadosPagamento[2],
ambiente: dadosPagamento[3],
bin: dadosPagamento[4],
idioma: dadosPagamento[5],
valor: dadosPagamento[6],
pedido: dadosPagamento[7],
descricao: dadosPagamento[8],
bandeira: dadosPagamento[9],
forma_pagamento: dadosPagamento[10],
parcelas: dadosPagamento[11],
autorizar: dadosPagamento[12],
capturar: dadosPagamento[13]
},
function(data) {
alert(data);
window.open('../negocio/index.php?mod=cliente&acao=gambs&xml=' + encodeURI(data));
$('#resultadoFinal').html(data);
}
);
The alert(data) I'm using just to test the response, and the problem is:
I send it to local test file (# window.open('../negocio/...') ), and then the response is working ok, otherwise in the webservice (https://comercio.locaweb.com.br...) there's no response, and the XML I'm waiting for doesn't even exist.
Does anybody know what's happening?
Or if I'm doing it the wrong way, could someone tell me a better way to get the XML sending data by Post?
Thank you.
Vinicius,
It looks like you are trying to use ajax to interact with a web service running on another domain? Browsers will not allow this due to the fact that they follow the Same Origin Policy when making ajax requests.
There are a number of methods to get around this limitation. One of which would be to host a proxy on your PHP site which performs the web request for you. Then your code can make the request the page that you host (which is allowed under the Same Origin Policy) but you are still able to call this service you require. There is a more detailed description of this limitation available on this page which even includes sample PHP code for this proxy page.
There is also a JavaScript library called easyXDM (which is mentioned in the Wikipedia article above). This library will determine the best method to use to perform this cross-site communication based on the user's browser. More information on this project is available here. I'm not sure how widely used easyXDM is in the wild, but I see that it does require that flash is installed on the user's computer before IE6-7. This means that would be expected that any IE 6-7 users of your site would have to have flash installed in order to use this payment service (could be a potential headache).
Personally I'm not a big fan of adding dependencies user dependencies like this unless I have to, so I would try to implement the proxy solution.
David Ipsen pointed out the Same Origin Policy.
To get around this, you can create a php file on your domain which would curl out to the webservice you want, and change your $post() function to call to the php file on your server via ajax.
Ok, I know what I'm about to say is going to be super vague, but hear me out:
I want to use flash messages because I like the idea of them, but they don't seem to always work for me.
Here is my workflow:
User creates a group on page A
I send an email notification to
members of the new group
I set the flash message "Success!"
I redirect the user to the newly created group and display the "Success!" flash message.
The problem is after I redirect the user, the flash messages are no longer in the $_SESSION. To make this even more strange, if I take out the step where I send email notifications, it DOES work. WTF?
Has anyone else experienced similar issues with flash messages? Does anyone have any insight into why sending the email would affect the flash messages?
I think at this point I'm just going to stick with setState and manually remove it after displaying them.
Now You can set a property autoUpdateFlash of CWebUser component to false. In this case flash message will be removed only after usage.
How is the email being sent? I know using the Yii Mail extension (a swiftmailer wrapper I think) in "debug" mode uses the setFlash method, so perhaps that's wiping out the array somehow...?
The "flash" variables are updated by the init() method of CWebUser, so if there is an extra call to CWebUser it's possible that's what is clearing out the flash variables.
Considering that you set the flash AFTER the email though, I'm not sure how that would happen. My only other guess besides the "debug mode" thing (not a problem if you are just using the PHP mail methods though) is that sending mail is triggering an extra redirect somewhere.
If you have a PHP debugger like XDebug installed I would set a breakpoint in the getFlash and setFlash code and get a look at what is happening that way.
Good luck!
On a website, I enter some parameters in a form, click on search and then get a page with a message "retrieving your results". After the search is complete, I get another page with my results displayed.
I am trying to recreate this programatically and I used Live HTTP Headers to get a peek of what is going on behind i.e the url, form variables,etc. However, I'm only getting information of what goes on up to the page which shows "retrieving your results". Live HTTP Header is not giving me information up to the page which contains the final results.
What can I do to get this final bit of information (i.e the url, form variables, etc)
I use Charles HTTP Proxy for all my HTTP troubleshooting needs. It has a ton of options and works with any browser.
"Web Developer" does this:
https://addons.mozilla.org/en-US/firefox/addon/60
#Mark Harrison
I have webdeveloper installed. Initially, I used it to turn off meta-redirects and referrers to get a clearer picture of the http interaction. But when i do this, the website does not work (i.e it is not able to complete the process of retrieving my search results) so i turned it back on.
I'm wondering if anyone has had to capture http information for a site that has a processing page in between the user input page and the results page
That sounds weird? I'm pretty sure that LiveHttpHeaders should show this. Can you double check that you aren't missing something? Otherwise try with Firebug. It has a tab for "network", which shows all requests made.
I'm using Fiddler2, which is a free (as in beer), highly configurable proxy; works with all browsers, allows header inspection/editing/automodification on request/response.
Disclaimer: I'm in no way affiliated with Fiddler, just a (very happy) user.
I for such problems always fire-on an Ethereal or similar network spying tool, to see exactly, what is going on.
The document is creating a browser component called XMLHTTPRequest , on submit event the object method send() is called, during the waiting time for server response an html element is replaced with a "Waiting message" on succesfull response a callback is called with the new html elements and then inserted in the selected html element. (That's called ajax).
If you want to follow that process you can use Firefox Live HTTP Headers Extension , or Wireshark to view full HTTP headers and actions (get/post/).