Email pipe to php script working only sometimes - php

I have a php pipe script that receives an email, takes an attached *.csv from it and parses it.
However, when the email is sent from where it is supposed to be coming from, it silently errors. But when I take that same email and resend it from my address it goes through just fine. is there any simple reason it could be doing this?

try and save some information about the email in a logfile before anything else, then some more info as you parse it. This way you get a more better understanding of what is happening

Is the email youa re sending from a real email? There may be a setting that allows emails to be sent from a valid user.
What happens if you chown the script to be the user you want to send the email from. Does it work then?

Related

Is it possible that a url link within an email can be auto-executed by an email client?

We have a script that executes different actions when a user clicks on a specified URL from within the received email. We are getting random records in our database as soon as we send the email to the user. We've checked that we do not have any PHP functions that execute those URLs. So we ask here, is it possible that a URL within an email body can be auto-executed by an email client?
No, that wouldn't be a good thing.

Tracking of email

Basically i want to make an app which will check that user has opened the sent mail or not
just like the script of "[http://www.readnotify.com][1]" like we have to just add
readnotify.com after the receivers email address before sending the email.
i have read that it is done by adding the img tag with very small size(1*1) in the email
<img src="http:/yoursite.com"/>
something like the above code and we got even the geolocation of the receiver.
How are they doing this behind the scenes??
means what they are doing in their PHP code ??
Image is generated by your script, which reads $_SERVER variables ( http://php.net/manual/en/reserved.variables.server.php ). Then you can get clients IP and so on. But rest assured, that most of mail clients do not open images unless user permits it beforehand.

How to affect a PHP program / mysql database from an email response

I am trying to work out how to do something. It must be possible - I've seen something similar done in multiple systems (Twitter, facebook etc.)
The basic thing I want to do is - someone leaves a comment on my website. The comment goes to my email, as well as to my MySql database. I then reply directly on my email. The reply is saved to the database, and auto-approves the user's comment.
I can't work out how to speak to my MySql / PHP system directly from an email. Also - I can't work out how to set up the inboxes?
I am guessing that I'd need to set up mailserver rules so that emails sent to xxxx-response#mydomain.com are actually redirected to a php script, where xxxx is an identifier of the original comment?
Thanks for any light that you can shed...
Assuming you're on a unix system, you could set up an account for receiving the mail, e.g. "fred", and use a .forward in fred's home directory to pipe emails to your php script. e.g.
.forward:
|"/usr/bin/php /path/to/your/script.php"
which will invoke your script anytime an email arrives in fred's mailbox.
You can't 'talk to mysql from an email'. An email is a passive piece of text, nothing that can take actions.
The solution is based on something like this:
You have an email account and poll that accounts Inbox by a php script in a periodical manner, by using wget or similar in combinition with a crontab entry. You can also create an event driven approach, but that is more complex and does not really offer advantages. For all messages found inside that inbox you check if it matches any previous entry in the database. You can do that since you have access to the messages headers and body (the text) by php. That is all you need. Typically the connection between two messages is done by evaluating the 'In-reply-to' header that is set by email programs when you press the reply button. It is like a reference.
The access to the accounts inbox is done by standard mail access protocols, typically pop3 or better imap4. When the mail server is not on the same system then abviously you want to add ssl encryption too. php's imap extension is a very good start for implementing such a client, it supports several protocols.

Script to Mail web page to a friends Email

I need a php script that you can use to set up a online newsletter and then have a link that will allow the visitors to email the Web Page as a Newsletter to someone elses email...
Is this possible? I suppose it is, as it is done here. That is exactly what I need. I want to set up a newsletter, add a script that will allow the visitor to send that newsletter directly to a friends inbox. http://www.pretoria.co.za/interactive/forward-newsletter.html
I suppose I just need the script to send an html file to the email address
Please help - thank you
Use a MySQL and mail function, or use e.g. this.
That can be written fairly easily using one of the email wrapper scripts, such as phpMailer. However, when doing so, pay particular attention to issues that could lead to spam and other abuse of the form. You should spend the time to really lock down the client-side, as well as server-side validation on all input variables.
That being said, the best way is to save the HTML of the page in a database, and pull it out into the body of the email. You should also include a text-only version as an alternate body so people without HTML email will be able to read it. Then, when someone submits the form, just validate the data, put together the message with the methods available with the mailer class you choose, send the email, and then redirect to a "thank you" page.

How to Check if a mail was received with php

i'm new in php. I want to send an email to someone and afterwards i need to check if this mail could be received. How do i do that? Hope you guys understand my problem ;).
Thanks in advance. Marc
That's a really sticky question. The only real way is to have PHP monitor an inbox to check for "undeliverable message" notices you might get back. If you're really wanting to go forward with it, look into POP3 connectors for PHP. Like this: http://pecl.php.net/package/POP3
if (strpos(strtolower($subject), 'undeliverable') !== false){
//do whatever you want with the address that couldn't be reached
}
You technically wouldn't need a compiled PHP extension for POP3 (especially if you're new to PHP)... you could connect and read messages by opening a socket and speaking mail server:
http://www.adamsinfo.com/a-rudimentary-php-pop3-example/
Edit (years later):
Definitely check out http://mailgun.net/, http://sendgrid.com/, and http://postmarkapp.com/.
If you're sending HTML mails, you could use a little trick:
generate a unique id for the mail you are sending (based on content and recipient)
include an image that is loaded from your webserver
<img src="http://yourdomain.com/tracker.php?id=1234567" />
in tracker.php, log the id that called the script and send a 1px by 1px image
This won't work though, if the mail client does not download images from the internet when showing an email, as Thunderbird does, for example (IIRC Outlook does so too)
There is no definite solution for this. Web bugs are a o.k. idea but they're dying out, as they are very problematic security wise and are blocked by default in every current E-mail client I know of. I would suggest a combination of checking a bounce inbox like brianreavis suggested, and in addition, requesting a delivery receipt using the following header line:
Disposition-Notification-To:<xxx.xxx#example.com>
That way, you can get most negatives (bounced mails) as well as many positives (receipts). Sending the receipt can be blocked by the sender, but together with parsing error notifications, you should have fairly reliable system.
One option is a Web Bug but these are far from 100% reliable, and are arguably not a nice way to behave. It won't differentiate between emails which are unread and those which are undelivered, for example because of a bad email address, and it is possible to read an email containing a Web Bug without triggering it.
In short you create an HTML email containing an element which has a URL on your site which is unique to that email. So if a client accesses that URL you can be sure that someone has read your email. Wikipedia gives this example:
For example, an e-mail sent to the address somebody#example.org can contain the embedded image of URL http://example.com/bug.gif?somebody#example.org. Whenever the user reads the e-mail, the image at this URL is requested. The part of the URL after the question mark is ignored by the server for the purpose of determining which file to send, but the complete URL is stored in the server's log file. As a result, the file bug.gif is sent and shown in the e-mail reader; at the same time, the server stores the fact that the particular e-mail sent to somebody#example.org has been read.
However, it is possible - probably quite likely - that someone can read your email without connecting to that URL. This may because:
A lot of email readers block such links by default because of privacy concerns precisely because of Web Bugs like this.
They read the email in text only, either because their email client is configured to do so or because it can't display HTML email, for example, a lot of mobile phone clients.
This is a often used option - both by spammers and more responsible marketers - but I probably wouldn't recommend it unless you fully understand its limitations and implications in terms of what people might think of you if you do use it.
There is a perfect solution, in terms of knowing the eMail has been read.
The bad part is that the body of the eMail must be stored on web server.
The trick:
-Send an eMail just just a small text and a URL, so the user must go to that URL to read de content of the eMail.
In other words... on the eMail there is nothing about what you want to send, there is only a link to a unique page you create before sending such eMail.
So to read the content the user must open a web browser and go to such URL.
The trick is to put a little of such text on eMail... something like: bla, bla, bla ... press here to read more.
The concept: Online body, offline URL to access such body.
That way you can be sure of this: if URL has been read, the eMail has been read.
The bad part is that the info you want to send is not on the eMail, must be on a unique webpage.
So you must control no robot can go to such URL... for example with URL like:
https://server/private/?eMail_Body=user
Hope this idea can help someone.

Categories