PHPMailer: sending email....ask for a receipt? - php

I am going to create a script that sends out an email. I am currently using PHPMailer. I have been told that they would like the email to request a receipt from the user indicating they read it. (like what you often see in outlook). I have no clue if this is possible. Can anyone tell me if this is possible and if so how to do it?
Thanks!!

See $ConfirmReadingTo in PHPMailer documentation
( More recent PHPMailer link on gitHub )

I'm not sure if you can use them in PHP or not a quick search showed this:
Disposition-Notification-To: you#yourdomain.com
however they are not reliable in any way as most email clients either ignore them or just allow the user to hit 'cancel' to sending a reply. I've only really seen it used in corporate/enterprise type env with Notes or Outlook.
Just something to consider, but depends on your application.

In PHPMailer you use $ConfirmReadingTo. You need to set it equal to the email address you want the confirmation sent to. Ex:
$ConfirmReadingTo: you#yourdomain.com
But some email clients (such as gmail) will just ignore this.
The best way to get a confirm from every email sent would be to send an HTML email and use a graphic to track which emails have been opened. The graphic source would be a script which you would let you check who has read the email. Ex:
<img src="http://www.yourSite.com/emailConfirm.php?FROM=someone#gmail.com&SUBJECT=The_Email_Subject" border="0" height="1" width="1">
emailConfirm.php could then generate an email to be sent to your email address.

You can use Josh’s recommendation with tracking image, but:
- use a special folder name and custom image name with .GIF extension
- track this image request by php handler, as an exception by accessing this non existing image
- generate this custom image name into the email
For example:
<img src="http://www.yourdomain.com/email/abc34642.gif">
Your php exception handler detects, that you are requesting a gif image in the folder "email", which means, someone opened your email with the identification 34642. You have to find, which recepient has this id, and you can find the neccessary information. I recommend using a generated xml file to avoid too much database queries. Don’t forget to output a real image with gif header.
This is absolutely safe against blocking your email with inappropriate image extension.

I confirm as of today the correct method is doing:
$mail->addCustomHeader("Disposition-Notification-To: youremail#mail.com");

Related

How can i know if an attachment has been downloaded from mail?

Recently I came to know that for mails we can,
1. Track Click-Throughs
2. Track Opens
Read more from this blog You Know How I Know You Read My Email?
Now I need to know how I could know whether someone downloaded the attachments in the emails.
Is this possible?
Thanks
Attachments are part of the email, so most clients will download it with the email (e.g. desktop clients, etc).
If you want to send a file and track whether it's been downloaded, then you'll have to host it online somewhere, and email the link. When the recipient clicks the link, the website where the file is stored can track when the link has been accessed and thus tell you the file was downloaded.
In general, you can't.
The attachment is embedded in the email. There is no way to track what happens to it afterwards unless the attachment has something in it that will allow you to track opens (such as a reference to an external image in an attached HTML document).
I don't think Its possible to trace attachment download.
Only you can trace you'r email checked or not by the receiver.
Via sending the small image in to the email and call you php file path.

How to generate a temporary email for use in a web-application?

Example: if I want to upload a video to some video service website (such as Youtube) by email, I can send a video to an email address (e.g 1234567890#upload.youtube.com). The number is an upload code - It's a unique number and changes every time. Then Youtube will process and upload my video automatically.
How did they create the email address 1234567890#upload.youtube.com, and how did they process an email message that a user has submitted?
I'm looking for the basic functionality behind this kind of web-application.
I've never done this, but I have a basic idea of how this is done.
There's a mail server on upload.youtube.com waiting for any email no matter who's the recipient.
Once it gets a message it will pipe it to a script which can parse it and get the recipient address (that's the uploader's unique identifier).
Then it will look in the email for the attachment and get MIME code, base64-decode it and then write it to a file on a disk.
Then it will add an entry in the database with the user's unique identifier and the link to that uploaded content.
if you use cPanel you could use something like http://www.zubrag.com/scripts/cpanel-create-email-account.php to create the email accounts (use your own routines to generate the unique username etc) then you could use a script like http://garrettstjohn.com/entry/extracting-attachments-from-emails-with-php/ to get the attachments from the email.
Finally, I figured out what I want.
All I have to do is handle with catch-all email on my web control panel. In my case, I just create a new subdomain and set a catch-all email option on that subdomain.
You can do all of above in Cpanel easily - just create a subdomain and selected a radio box Pipe to a Program and fill your application path. That's it!
Unfortunately, I'm using DirectAdmin. I have to do more complicated than Cpanel. It can handle with catch-all email as well, but I have to use wildcard dns for my subdomain record first.
In addition, I found this useful article about how to Pipe / Send Email to PHP Script. This article will show you every step including a PHP script for using with email piping.
Thank you for all answer. It's very helpful.
That's nice to know that you have achieved this.
I am here to introduce you to a script that can help you. The script is dealing with the dynamic email addresses with PHP. You can see the script at github and there is a premium version of this software you can see a demo here. You can buy the script from codecanyon.

How can I force email programs to show images send in html email using php?

I am sending an html email with php and it includes an image. Some email programs, such as gMail have a 'display images' button. The user has to click on that in order for the images in the email to show up.
Is there any way I can force email programs to show images that are sent within html emails generated by php?
As a rule of thumb, email clients are configured to display attached images by default (e.g. those with a cid: URI scheme) and not load remote images (which can include tracking information).
If you attach all the images, then you'll usually get them showing up (while inflating your SMTP bandwidth use along with that of your recipients (which can make you unpopular)).
I'm afraid not. The main reason email programs block images is because images are often used to 'report back' to whoever sent the email that the email has been opened. This is a common tactic used by spammers. Also, malicious code is often attached to images and downloading these images is how such code gets executed. Another reason email programs block images.
No, you can't force programs you didn't write yourself to do anything.
Email is hugely variable, and in general you're going to see different results in different places. That being said: There's no general way to force an email client to display images; this is why most email now includes a link at the top indicating that if it doesn't display correctly the user should click on it (which then takes the user to a standard HTML page outside the email client's image/javascript/everything-else-blocking grasp).
You specifically mention gmail so it's worth pointing out that if you embed (CID URI) the images they won't show inline, they'll show as attachments at the bottom of the message.
Doubt it, it would be a security issue if the 'src' of an image opened up a cross site scripting attack.
Cross site request forgery
Customers of a bank in Mexico were attacked in early 2008 with an
image tag in email and were sent
through their home routers to the
wrong website.
You can, but unfortunatley Trident, which is the IE rendering engine doesn't support it (surprise, surprise), but it is technically possible to include images in the html itself - see http://en.wikipedia.org/wiki/Data_URI_scheme
The last place I worked, we were sending out emails that had images in them that would come up automatically, in outlook at least, without me having to explicitly click a show images button.
When I inquired, another developer explained that they simply copied the encoded block of the image from an already sent email into the body of the email. I think this may be a weird sort of workaround they stumbled upon. I don't know if this adds more weight than an attachment, but I could see how an email reader would see an attachment and then ask the user as opposed to read it already in the body and just show it...

verify email opened

once we send email from php using mail() function, is there any way to check either mail is open or not?
may be any type of database insertion code in email..?
or calling any function from website?
any possibility.........
i search on internet all the day but did't found any ans.
Thanks
Small images - called Web Bugs - are the only direct way as Szere Dyeri points out, but they are increasingly frowned upon and blocked by every major mail client for privacy reasons now. I would not consider them a reliable way to tell whether an E-Mail has been read any more.
There is a legitimate way to request a read receipt by adding the following header to the E-Mail:
Disposition-Notification-To: your#address.com
Sending of this notification can be turned off by the recipient of course.
Add an invisible small sized image to the email content. And, let the image point to a unique url on your website. You will know that email is opened once that url is accessed. But this will not work in email clients that does not show images in the emails by default.
I found this web service called Get Notify. They claim they do this for free but you need to verify for yourself.
The only way to do this would be to include an image in the email that resided on your server which includes a key to match to the user you are sending the email to. For example, I send an email to Joe#mail.com. In my database (or other storage system) I have Joe#mail.com matched to key 0100. In his email I include an image, like
<img src="http://www.myserver.com/image/?key=0100" />
On your server, /image/ needs to return an image, even a 1 pixel .png. Now you have the key that the user was assigned and can act accordingly.
Many people responded that adding a "tracking image" is a "frowned upon" method and 'considered "questionable" activity'.
Out of curiosity lets say we didn't include a separate tracking image but rather we included this method in an existing image like for instance added it onto your companies logo image like:
http://mycompany.com/images/logo.png?track=2742'>
At least with this method your tracking image won't get blocked by any scanning applications.
One legitimate way to do this is to only send textual information in the email asking the user to follow a link which you can then track. Something along the lines of:
//lots of good info to identify yourself/company
Thank you for your request...
Please follow this link: http://somewhere/ for tracking information
Unfortunately this leaves it in the users hands to acknowledge your request. This is considered to be the most respectful way to do it.
If your application is not public facing (i.e. an internal app for your company), then the img src method already posted is a good technique.

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