How can a Qt C++ app request the OS to send email with a specific subject, body and possibly an attachment(s) files? It should be dispatched using the configured default email client.
It looks like QDesktopServices::openUrl() will accept a mailto: URL. But specifying an attachment could be tricky.
I've written a small component that handles attachments too. It creates a temporary .eml file filled with the content that you provide to the Email class and opens the default email client with openInDefaultProgram(). The API should be self explaining, but if you have any problems, please don't hesitate to contact me :)
https://github.com/picaschaf/qt-email
Related
Currently sending emails with Django, and was wondering if there was any way to periodically check my inbox with Django (or ideally somehow alert the server upon receipt of a new email), and have Django extract the message and save it in the database.
You could use an email service such as SendMail or Mandrill (latter definitely has free accounts, former may have).
Each of these services provide inbound email support via webhooks. You provide them an endpoint to hit (make sure to use HTTPS) and when they receive an email to an address you have registered they will send the data via HTTP POST to you.
It is then just a simple case of storing this data to the database. There are a number of 3rd party packages that can help you with this:
http://djrill.readthedocs.org/en/v1.4/usage/webhooks/
https://github.com/yunojuno/django-inbound-email
https://github.com/jpadilla/mandrill-inbound-python
https://github.com/michaelhelmick/python-mailsnake
Although it's rather simple to roll your own should need be.
Is it possible for Mailgun to POST only the non-attachment part of emails to my API, to prevent big attachments affecting the performance of the app?
Mailgun can host the attachments for you with the inbound functionality.
You can use the Events API command store(notify=”http://myapp/post”) specifying as shown the notify option, which will send a webhook to your application with a URL on message arrival.
One of the headers sent with through webhook will look something like: ["[{\"url\": \"https://api.mailgun.net/v2/domains/YOURDOMAIN/messages/ALARGESTRINGOFCHARACTERS/attachments/0\", \"content-type\": \"META/META\", \"name\": \"MYFILE.EXT\", \"size\": 74622}]"]
Then you can retrieve it and delete the stored message.
Keep in mind that stored messages are kept only for so long so you should process attachments rapidly.
This is one of the options of the routes functionality that Mailgun gives you.
Personally I love it ! Let me know if something is unclear i can dig into more details!
Best,
I am getting mail on the Mailgun which I am routing to my local server and their. I am parsing the JSON but problem is coming in case of attachments. In attachment json, it is showing the path of temporary file on mailgun server. I need to download the attachment and store it on my local machine.
My question is how to retrieve that attachment. Do we have any API for that?
To access the data from the link, you will need to specify credentials as your get parameters. The user is 'api' and the password is your mailgun's private key
Please refer to this answer that I've given here
The use case:
User makes order his payment gets accepted and his details are getting post to a django's view. Using these details django's view creates user and everything that is necessary (Username and password is provided by me). Then before returning it sends email to clients email with his data (Username and password for now).
But sometimes I get a gateway timeout error from apache(app is deployed on openshift). Because the user is created I assume that the timeout comes from the email sending part. How can I make sure everything went ok and inform the user? How can I make sure that if the email isn't sent I can resend it? What is the best practice at that?
If you have timeouts with an API or Service, you should fire your POST / sendmail request with AJAX...
Serialize the whole form (like jQuery's serialize())
Send that data via AJAX (with jQuery's ajax())
Inform the User of success or error (alert() or jQuery UI dialog)
You can find a lot of examples on this website.
Another "dirty" approach would be to add the attribute target="_blank" to your form tag what opens your lazy request in a new tab / window.
My company is working with the amazon MWS api, and we are receiving a lot of messages from the customers about their orders.
Is there any way to get these messages using the web services and reply to them?
As #joshubrown pointed out correctly, there currently is no API to get customer messages or send replies. You can, however set up a separate mail account for that purpose, which (depending on your own server architecture) gives you a whole set of protocols like POP3, IMAP, SMTP or even MAPI. Regular emails sent to the "scrambled" customer email addresses will be relayed to the consumer and will shown up as replies in your Seller Central.
No, there isn't a public API for that.
How I was planning to do this (in the absence of an API) was to set up the email account (that would receive the emails from customers) such that it pipes the email content into a script. The script would then write the content to the database (or do whatever you want with it).
I'm using qmail for mail, and if you edit the .qmail file within an email account's folder you can set where to pipe the email content eg
| php /pathtoscript/emailHandlingScript.php
Other email systems will have a different syntax for this.
Then in your PHP code (if you're using PHP), you can grab the content from the stdin stream:
$fh = fopen('php://stdin')
I'll probably use PHP's mailparse functions (eg mailparse_msg_parse_file, mailparse_msg_get_part etc) to properly extract the data from the stream.
As #Hazzit points out, when you reply to the anonymised email address (eg qwugwquigduwqgiqwdgiuwqdg#amazon.co.uk), Amazon will pass it on to the customer.
I created users on my account, redirected mails and made a script to read and reply.
I'm currently designing a solution with this pretty standard pattern:
1 web-app using Django (it hosts the one and only DB)
1 client mobile app using AngularJS
This client app uses a REST API (implemented on the Django Server with Tastypie) to get and set data.
As a beginner in these architectures, I'm just asking myself where the logic should go and I'd like to use a simple example case to answer my concerns:
On the mobile client App, a client is asked to subscribe by entering only an email address in a form.
a) If the address is unused, inscription is done (stuff is written on the DB).
b) If the address is used, an error is raised, and the user is asked to try again.
What is the workflow to perform these simple operations?
I'm asking for example how to compare the entered e-mail address in the mobile app with the existing e-mail adresses in my DB:
Should I GET the list of all email adresses from the server, then perform the logic in my client app to state if the entered address already exists ? This seems really a bad way to do because getting lots of elements isn't performant with web services, and client should not be able to see all email adresses.
Should I send the entered e-mail address to the server and let it make the comparison? But if yes, how am I supposed to send the data? As far as I know, PUT/POST are made to write in the DB, not to just send data to server to analyse it and proceed some logic.
I have the feeling I am clearly missing something here...
Thanks a lot for help.
PUT and POST are designed to be used to create and update resources. The server may or may not have a database behind it. It might use a local filesystem, or it might handle anything in memory. It's none of the client's business. It is certainly common to have business logic on most servers which provide APIs.
Use PUT/POST to send up the email address to the server. The server checks to see if the email address is (a) valid, and (b) allowed. If it fails either check, return a relevant response to the client as documented in the RFC. I would go with 403 Forbidden, which indicates a problem with the data being sent up to the server. Use the entity in the response to detail what the problem was with the request.
I had done similar thing in a angular web app,
I have disabled the submit button, and added a check availability button beside the email field.
I have send the email to server and checked if it already exist and got the result to client,
then asked the user to enter an alternate email if not valid or enable the form's submit button
Alternatively
when the user leaves the email field, You can send the email to a service that validates the email, and get the response, and show a message that this email already exist and disable the submit, or enable the submit button otherwise