Emailing Processing Bounces - php

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

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.

How to get an email delivery acknowledgement using PHPMailer?

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.

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.

How to weed out bad emails (in php)?

I have a site where users register for an account. I have an internal communication system, that sends them an email when they get a private message. I dont force people to confirm their email, so naturally, many enter a fake address.
When they get a PM, it tries to send them an email, but obviously fails, so it keeps retrying and retrying. After a few weeks, the retry queue gets quite big, and it affects server performance (I also dont wanna get blacklisted for all these attempts).
What can I do to solve this issue (other than force people to confirm their email upon registration).
If you don't want to force people to confirm their email because if something goes wrong, they can't access their login straight away, why not do something like this:
If they haven't confirmed their E-Mail, don't send PMs, but show them when they are logged in instead. Remind them to confirm their E-Mail.
If they have confirmed their E-mail, send them out.
But anyway, your scenario sounds like a server misconfiguration. Why would a mail server keep re-sending mails that it got a "not deliverable" message for? As far as I know, re-sending mails only occurs when the receiving host was not reachable for technical reasons.
You really should just require confirmation.
Short of that, you can deactivate users whose emails have bounced a certain number of times, and require a new email at next login.
It will be hard without verifying, but you can at least verify the domain it's coming from:
Option 1: Use getmxrr to search for MX records on their hostname
Option 2: Use checkndsrr to check their DNS info
But all these really do is check the validity of the domain, and whether it's running a mailserver. To get real authenication a confirmation is the best way. You could also implement a tool to send out a test email, and see if it bounces back. But this method may not always work as expected, because of variations, some servers it's instant, others it can be a day later to return an undeliverable email.
I hope this helps.
consider having a checkbox so that people can opt-out of email notifications. if they do not enter a valid email address, it is surely because they do not want to receive emails in the first place, so let them tell you.
additionally, you may consider having an opt-in system, where people will not receive email notifications in the first place and have to enable it somewhere in their account settings, providing an email address at this moment. this way, the number of fake email addresses will be reduced to near zero.

How to handle mail delivery errors with PHP

I am building a symfony module for sending newsletters. the idea is to build a queue list of adreeses to receice the mail and then ,with a cron job, send let's say 50 at a time.
What i don't now how to do is to read the Mail Delivery reports that are sent back by the server when an email adress doesn't exist or the mail is full. The idea is to store these error reports an clean the adress list.
Any ideea how to implement that?
When reading the "bounced inbox", you can use a class like this to actually parse the mail and see what status was returned (e.g. permanent or temporary error):
http://www.phpclasses.org/browse/package/2691.html
To really parse a mail accurately will give you a hard time, as not all mailservers are alike and some will send you a "mailbox full"-error marked with a "permanent" flag while others may tell you that the error "user doesn't exist" is "temporary".
I tried a solution for this once and ended up setting up my own parser connected to a huge database containing possible server replies (and their "real" meaning :).
You can use a reply to address while sending. So bouned emails will be sent to this id. You can also create another PHP script which will read this "reply to" email inbox and get the id from it. You can then remove this id from the list you have.

Categories