How to get an email delivery acknowledgement using PHPMailer? - php

I am using PHPMailer to send emails, I need to rectify which of my emails have been reached successfully to receiver's inbox. Is there any way to get the acknowledgement or delivery receipt for each email sent?
If possible I need those email id's inserted into my MySQL database.

There are several approaches to this, none of which are reliable.
You can request delivery receipts by adding the Disposition-Notification-To header. PHPMailer has built-in support for this:
$mail->ConfirmReadingTo = 'confirmations#example.com';
Not many clients support this, and even if they do, it's likely they have it disabled for security reasons. Generally it's only likely to work within company intranets.
Secondly you can add an opening tracker or beacon image in your message body so that when a clint opens the message, the loading of the image tells you which message was opened. You need to embed a unique identifier for the recipient and/or the message in the URL, such as a hash of the email address and timestamp. Again, this is not reliable because most clients have image loading off by default, or the images may be opened by inbound mail scanners, giving you false positives.
The most effective way is really to get to know your mail server, and handle bounces correctly, but even then, just because a message has been devivered successfully to the recipient's mail server does not tell you whether it reached their inbox, nor whether it has been seen or opened.

Related

php imap: can't see actual recipient if bcc

I'm working with PHP IMAP functions to poll an inbox and process the emails. Sometimes the emails are received via bcc -- this email was bcc'd by the sender. I need to be able to retrieve the actual email bcc'd -- but imap_fetchheader and imap_rfc822_parse_headers don't provide that if the recipient is bcc'd (even though it's in the return spec).
The issue is that I'm using plus addressing (myemail+value#domain.com) as part of my script, so it's not sufficient to know the email landed in my inbox -- I need to know the specific version of the address it was emailed to.
I understand the whole purpose of bcc is to be hidden. But I would think that there should be something in the header of the bcc-recipient to indicate the email was sent to them.
The "bcc address" that message is sent to is not part of the message itself, it is part of the message exchange protocol. It is used on the protocol level of smtp whilst handing over the message to the receiving server. The content that is handed over, so the message payload itself, is something different. There is no way to read that address from a received message by means of a protocol like imap4 or pop3. You'd have to scan and parse the smtp servers log files for that.
You can easily check that yourself: open the source code of a message received. So the original, technical payload including everything. That looks ugly, but it shows all information actually contained in the data. You will not see any mentioning of "bcc" or a "bcc address" in there.

Do I need to whitelist any IPs to use Mandrill API?

I am trying to send mail using Mandrill API and I have got following responses :
[{"email":"_emailid_","status":"queued","_id":"772237d78ce74e5c9bd8ccbd9a1cfb8c"}]
{"email":"_emailid_","status":"scheduled","_id":"10a0b596a95e44ddb5e8cf504e3899ce","reject_reason":null},
{"email":"_emailid_","status":"scheduled","_id":"b699d58f021b43b2a0b25d801d1b4f91","reject_reason":null}
But I am not getting any mail on the email addresses sent. Please help.
Do I need to whitelist the IP of the system from where I am doing the curl call ?
You do not need to whitelist any ip addresses, you however do have to configure the DNS records for your email domain properly, head over to the domain settings page in the mandrill control panel for more information.
Everything seems fine.Either your you are not providing correct email to api or mail are coming to your spam folder.You need to check mail from address which you give to the api.
It looks like at least the last two were scheduled, which means they won't send immediately, but rather at the scheduled time in the future. You'll probably want to double check the time and date that they were scheduled to be sure.
For the first one, there are a number of reasons that emails are queued, including if they have attachments that need to be scanned, or if they're part of a large/batch API call. We'd need more information about the API parameters that you passed to determine the reason for it being queued and/or what happened once it was queued.
You can search your Outbound Activity by the recipient email address, subject line, sender, and a number of other criteria for emails that have been sent. Messages that are scheduled but haven't sent yet cannot be searched since they've not been processed. For any messages that have sent, click on the word "Delivered" on the Outbound Activity page to see more details about the response that Mandrill got from the receiving server when delivering the message.

Emailing Processing Bounces

I have a database that contains 20K of what the email I was sending newletter The problem I found was that each of the email I sent back type
Delivery Status Notification (Failure)
I am willing to transfer this email which is inactive knowing that I filter all email from the standpoint of the field formatting and existence.
as I have to see how little research has addressed this problem I find the notion that bounces are already implemented on the software.
If any one has any That a idea how I can apply that bounces in the php will be welcome
cordially
Well, it's pretty hard to understand what are you talking about, but...
As you mentioned, when e-mail can't be delivered (for many reasons) you will get Delivery Status Notification which will goes to inbox of e-mail that you used to send the message.
For example, if you send newsletter from newsletter#test.com to customer#test.com and the message can't be delivered then you get notification at newsletter#test.com. So just open your newsletter#test.com inbox with php, read the messages, parse them, and save the errors (if occurs) in database, matching by e-mail.
This link could be useful:
http://php.net/manual/en/function.imap-open.php
If you have your mailbox at your own server then the thing is much simpler, because all you need to do is to make ln, and then just open the file to parse.
ln -s /var/mail/my-inbox /var/www/my-script/inbox

Detecting bounced messages

I am working on a tool that will be sending bulk messages (not spam :) and I need to add a feature that will detect bounced messages. Is there a standard response associated with bounces? Would it be in the header of the body?
This is typically achieved by setting the Return-Path header of your outgoing Mail to a unique Address for every recipient. For example, you could use bounce+userid#example.com if you have a unique userid identifing every recipient.
If the Mail gets bounces, you recieve it and parse the reciever (which will bounce+userid#example.com), you can then take appropriate actions.
Using the + syntax makes it possible to create a single mail-user (bounces#example.com) which recieves all bounces and still distinguish between the recipients.
You can not rely on either the headers or the body of the bounced message to be able to reliably identify the original recipient, especially if you want to automate the process. Even if you add your own custom headers, it's likely that the bouncing server will strip them when it sends notification back to you. And trying to parse text in the body of the message in order to pull out the recipient's email address can be dodgy at best, as there's no standard format and every bounce you get will be different. The only piece of information that will remain completely untouched in a bounce is the return path email address -- the address that your server advertises it wants bounces sent to. Thus, the only way to automate truly accurate bounce catching is to encode the recipient directly into the return path address itself.
This would typically be done by overriding your server's default return path address for each outgoing message, using a unique value per recipient, like bounce-XXXXX#yourdomain.com, where XXXXX is some encoded and/or obfuscated representation of the recipient's email address or some other internal identifier. This technique requires the use of an email server which can support this type of wild card catch-all address so that you don't have to set up a new bounce account for each email address you're sending to. Assuming that, you simply configure the server to dump all such bounce-* emails to your script, which needs only to decode the XXXXX in order to determine who the original recipient was.
If your tool is going to be talking directly to the recipients' SMTP servers, it
might be more advisable to check the error codes returned via the SMTP protocol for
4xx (temporary failure, e.g. "mailbox full") or 5xx (error, e.g. "no such user")
responses. Due to antispam/backscatter prevention mechanisms, you shouldn't rely on
the recipient's server to reply with a non-delivery report whenever a message doesn't
go through.

How to handle email address status in PHP?

I'm developing an email marketing system which allows users to send emails to multiple addresses. I have a list of tasks that need to be done, probably I will have many questions regarding to these tasks. Here's one of them: As I said, users are sending out emails to multiple addresses. I want to check for every sent out emails if the receipient address blocks the email and the reason of the block.
Usually this is coming back to an email from Mail Delivery System. I think the solution has to be somewhere around the idea of checking the incoming emails somehow. Please help me finding the best solution.
Thanks
**
UPDATE:
**
I'm going to update the content of the question. I forgot to say that these emails are sent our from a valid SMTP server with username and password, there should be a way to get the content of inbox from PHP somehow.
I want to check for every sent out emails if the receipient address blocks the email and the reason of the block.
Forget it. Most spam filters will just swallow unwanted E-Mail without comment (so as to not give spammers any hint about their success or failure).
Also, you won't be able to find out if a user simply deleted your E-Mail straight away, or had a rule set up in their E-Mail client to delete it. This is information that you will never get hold of unless the recipient tells you.
Only a tiniest fraction of rejected E-Mails will actually cause a reply to go out to the E-Mail sender address - if any! I, for one, have had mails swallowed by spam filters, but I've never received a reply saying "your E-Mail was filtered as spam". Have you?
What you can do is catch E-Mails whose delivery failed for technical reasons - unknown recipient, recipient mailbox full, relaying failed... Those will be returned as "mailer-daemon" error messages to either the sender address, or the address specified in the errors-to header. Those mails you could parse using PHP. But I don't think this is what you want.

Categories