First of all I am aware that e-mail recall rarely works, and then usually only with Microsoft Exchange server.
Despite the limitations, a client has requested this feature.
My understanding is that the RECALL functionality in Microsoft Exchange is a proprietary extension of the SMTP protocol, and sends a new e-mail asking for a RECALL to the client. The client then does its best to recall the message.
I have found no documentation on what the RECALL extension to SMTP is, and I don't really fancy pulling out wireshark in order to trace it yet. I did found suggestion for an RFC extension of SMTP in progress https://datatracker.ietf.org/doc/html/draft-leiba-morg-message-recall-00 and I assume this is similar to Microsoft's solution.
Since our solution is PHP based, I am therefore asking:
Does there exist a method in PHP to send an SMTP recall request for a previously sent e-mail?
Regards
Dagfinn
I don't think this has anything to do with SMTP.
Rather, if you try sending a recall message to your non-Outlook operated email account, you can see that it's simply an email message. My guess is that either the receiving Exchange server or your Outlook client will recognize such messages and perform the appropriate action.
The content of the recall message seem to be quite simple, with nothing of obvious interest in the email headers. The message body (which I cannot view in plain text form where I'm at right now, unfortunately) simply says:
John Doe would like to recall the
message, "foo bar subject".
In any case, I doubt any PHP email library supports this out of the box. However, it should be fairly easy to implement, since it probably just requires you to create a proper email template and fill in the blanks with a subject, name and perhaps a message id.
Does the client specifically ask for interoperability with Exchange and RECALL, or is she using that as an example of whats she's after?
If it's the latter I suggest you propose an alternate solution using a grace period before the e-mail is actually sent to the SMTP server. To the user it'll look like the e-mail is sent but she'll be able to undo the send within the grace period (for instance 10 minutes).
--
Alf
There is an SMTP extension for Recalling message since 2010, however it seems that none of the SMTP servers are supporting this.
https://tools.ietf.org/id/draft-leiba-morg-message-recall-00.html#anchor1
Related
I'm using Laravel 5.5. In my app, users can write something and send it through email to someone. The thing they wrote gets recorded as a "message" in my DB. I need to, somehow, send the ID of this message in the e-mail, so when the receiver replies through e-mail, I know which message he's replying to.
What's the easiest way to do this? I know there are APIS, but I need to implement a custom solution.
Thanks for any light on this.
Use extended addressing on your mail server - replies+specialcode#example.com ... although a lot of bad "email validation" methods think it isn't valid, so I changed the extension character to a hyphen instead of the + on my postfix setup.
All mail is delivered to replies#example.com but the to: and other headers keep the specialcode part which you can then use to route into a ticketing system, etc.
This feature is supported by Postfix (recipient_delimiter in main.cf), QMail, and several other SMTP servers. Note that you need the support for this on the incoming-to-you SMTP side, nowhere else, especially if you use a character that isn't typically declared as "wrong" by various filters. May be worth splitting off a subdomain so you can easily set up separate MX servers, etc. since I'm sure you don't want your regular corporate mail running through the same filters and processing (at least, I would...)
I'm currently trying to design a PHP webapp that allows users to send emails to other users. The recipient can then reply to the email and the message will be updated in the webapp.
Now to keep track of each individual user message, I would like to add a custom header (ie. conversation_id) in the email. When the recipient replies to the email in their email client, will the custom mail header (ie. conversation_id) be preserved?
There will be cron job that executes every minute that opens a POP3 stream to the web server to retrieve new emails (replies that the user may have sent with their mail client) to update my DB.
I'm not sure if this is a good way for designing such an app. Any suggestions?
EDIT: Also, I'm sure wondering how I can strip out the quoted messages in the reply?
You can't rely on mail headers being preserved - it is pretty much up to the individual mail client to decide what to include.
I would generally put the conversation ID within [] brackets in the subject which makes it really easy to parse out with a regular expression.
Each message already contains the Message-ID field which is used by the mail clients to create the content of the In-Reply-To field.
Wouldn't the usual way after the standards be to rely on the user's mail client setting the in-reply-to field correctly? As far as I know, all email client use this correctly. (even though according to this thread Outlook may have an occasional bug?)
So I think, emails already feature this and you don't have to worry about creating a custom mail header entry and unpredictably behaving mail clients.
EDIT: I rembember a friend telling me his frustration from work about how many people remove or even edit these Tags in [ ] brackets from the suject field. Also, it seems to be a very dirty work-around and all of your software would need to handle it without opposing it to the users ability to change it => practically impossible.
EDIT: I think it will be hard to reliably strip out the quoted message in the reply, because each mail client handles it differently.
What would be the best way to manage the emails bounces/errors if you are building a web-mass-mailing software ? I plan to use PHP for that.
Before someone start screaming, yes, the lists will be from valid customers who have opt-in.
I know there are desktop software or third party website that can manage such things. I would like to display it with a design similar to the current CMS's visual and be accessible in there.
If the only solution is to connect to a mail server and read the bouncing back messages, then I will head that way. Then, how would you parse the data to flag that email as "invalid"?
Thank you
One possible thing you could do aside from having a PHP script read mail from a pop/imap server would be to pipe incoming mail for a certain address to a php script. See Google
You would then read the entire contents of the message in by doing something like $email = file_get_contents('php://stdin'); I've installed the php extension mailparse to assist in parsing RFC emails, but there are other options available. You don't even necessarily have to use anything to parse the message.
Once you have the message, there are a number of indicators you can use to try to flag a message as a bounch. First, see the Wikipedia article about Non Delivery Reports, specifically Format and RFC 6522 - The Multipart/Report Media Type for the Reporting of Mail System Administrative Messages. You can also check for common headers in the message such as X-Failed-Recipients or Diagnostic-Code.
Once you've determined a message as a bounce in the PHP mail processor, you can take appropriate action and set a flag in the database related to that email. Mind you, some errors may not mean the address is no good. For example, if a mail server is down for a few days, your MTA may give up, but it doesn't mean the address is no good. Also a user's mailbox could be full.
It wouldn't be a bad idea to log a copy of the bounced message so it could be checked by a person if necessary to diagnose an issue or reverse the flagging or a particular email address.
Here are some additional references:
http://forums.theplanet.com/lofiversion/index.php/t89873.html (note Improvement possibility 2)
https://stackoverflow.com/questions/5700034/how-do-i-process-a-bounce-email-to-find-the-error-code
Bounce Email handling with PHP?
Hope that helps.
We are setting up a bulk mailing system using sendgrid as our core.
We are managing the lists ourselves and sendgrid is simply our transport and are using code igniter to build the system.
We are wondering what you would recommend we use, sendgrid as an smtp server, or use it's curl API.
We are sending emails out to x00,000 people every day, the emails all have the same content.
We have found SendGrid's integration documentation for code igniter which only has smtp examples, so possibly that is the way to go?
The other part of the question is, if we were to go with the SMTP api, how does code igniters bcc_batch_mode work?
I currently work at SendGrid. Our web API actually works faster than SMTP, as you only need to make a single cURL request to us to send a message, whereas with SMTP there's a lot of back-and-forth TCP chatter for connection, HELO, and such.
We recently published a new PHP library, you can find it on our github account: http://github.com/sendgrid/
Don't hesitate to contact us if you have questions.
Reading the documentation at http://sendgrid.com/documentation/map/version/v2#api
there is little to choose between them. All functionality is available either way. For PHP, I recommend smtp server with their SMTP API to take advantage of existing libraries that correctly format, mime encode, and send the email. Notably, example PHP code is given only for the SMTP API.
Edited for additions to question
The sendgrid documentation say to encode multiple recipients with their API in a custom mail header -- X-SMTPAPI --not using CC and BCC. See http://sendgrid.com/documentation/display/api/SMTPDevelopersGuide
http://sendgrid.com/documentation/display/api/SMTP best practices section for issue with multiple recipients in the regular mail headers.
Ok, so simply as a reference for anyone I am going to paste my support chat. Note that this chat covers a wide range of things so could be useful to have it stored here
me: Sending to multiple recipients using code igniter?
Hi there, I am a php developer using code igniter, we are using sendgrid as our email sending platform,
Support: Hello.
me: Hi,
Support: Let me see if I can find a reference in our docs.
me: I believe you are going to reference: http://bit.ly/jL1Pde
Support: That was the one I was looking for.
me: Yes, I have seen that, But I also saw http://bit.ly/jvowuk which says you should use the X-SMTPAPI header, so I am a bit confused as to which I should use?
Support: Use the Codeigniter example from the previous link. You could use X-SMTPAPI, but is not needed in this case. The reason is for better portability with other languages.
me: Oh I see, Thank you very much, I have one other query.
Support: Ok.
me: When sending emails is there any header we can send to associate extra information with an email (for example a id from our system) to help with the lookup?
Support: You can set a custom category if needed. setCategory(cat) Sets a category for an e-mail to be logged as. You can use any category name you like. This is from http://bit.ly/iYjq2G
me: Oh I see, thank you, and sorry to be a pain but I have one more question,
Support: Ok.
me: We wish to provide our users with the ability to unsubscribe from receiving emails, All emails send through in a specific batch (e.g. 100,000 emails) will have the exact same content, with the exception that we want to append an unsubscribe message to the bottom, We want to be able to track the unsubscribe back to a specific message sent from our system, so we will want to have the url look something like http://example.com/unsubscribe/1234, 1234 being the unique id for the message sent, does sendgrid provide an easy way to complete this, or must we do an individual request for every message?
Support: Ok, so you can do this using: addFilterSetting(filter, setting, val) Adds/changes a setting for a filter. Settings specified in the header will override configured settings. Here is an example of the parameter being enabled in PHP: $hdr->addFilterSetting('subscriptiontrack', 'enable', 1);
me: ok so looking at http://bit.ly/k49a57 it says about your custom name to appear in the link, what exactly does this mean? as we do not wish the user to be sent to sendgrid to unsubscribe.
Support: So, it allows you to make the link say something different other than what we provide such as 'Remove myself from this company' for example.
me: Oh I see, So if we wish the url to be something personal we must manage this ourselves, this is fine, I cant remember where, but I noticed somewhere there was something about substitutions for the email content, would this allow us to send through a list of ids and in our email body we could have *example.com/unsubscribe/--email_id--* and have it replace the *--email_id--* with the passed id?
me: Ah, http://bit.ly/jvowuk point 2 is what I was referring to, could I use that?
Support: Yes you could do that.
me: ah, here is a better example, http://bit.ly/lK6ltE
Support: Yes, that shows the e-mail with substitution. So, it can be modified for each.
me: So, I can use *$this->email->_set_header('Custom-Header', 'value');* in code igniter to set a custom header, if I was sending out say 3000 emails, I have an array that looks like array(5,6,7,8...) with the ids, 3000 of them How would I send these through? (if it is not a quick answer I can work it out by looking in the SmtpApiHeader class)
Support: The SmtpApiHeader is the best way. Adding them as parameters for the substitution. Each indexed ID.
session disconnected.
Is it possible to send mail asycronously using PHP while giving live user feedback on delivery?
I have recenty written a small app for our company's intranet for sending formatted emails to customers. The interface is quite clean and only requires the input of a job number, it then builds and sends the mail. The mail, while being built, obtains a number of attachments from another server and everything is automated. The library used is PHPMailer.
Is there a way, using other technologies, possibly, but still using PHP as the main language, to show progress of the mails being sent? I have coded robust error checking to check if the mail was actually sent, etc. but i am missing a way of giving users the visual clue of actually delivering the mail to the server via a progress bar, etc.
Is this possible using PHP and something like Ajax? How would you determine the progress of the mail in transit?
I'm not familiar with PHPMailer, but you certainly need support of the library to be able to query it about the status of the emails being sent.
Given that PHP doesn't have threading, I would suggest having a database queue for deliveries, and have an external PHP process triggered from the main site (or via cron) that processes the deliveries on the side, marking on the database the current status on each delivery: NOT_PROCESSED, IN_PROGRESS, CONNECTING, CONNECTED, SENDING_DATA, ACCEPTED, FAILURE_X . You can query the database for the status on each delivery via Ajax.
If PHPMailer internally uses the standard PHP mail() function, which uses a relay SMTP server in your machine, you cannot have that much information about status (which you would have if you created the sockets yourself), you can have just three main states NOT_PROCESSED, IN_PROGRESS, FAILURE_X.
(FAILURE_X really represents many states, as it explains the reason for the failure).
A final consideration on using mail() is that the status you'll be able to know is just the status from the local SMTP relay, which will always accept very quickly, and you won't be able to tell if the mail was really delivered to the outgoing server (at least not without having to interface to it or read mailq, which are nasty things to do).
DISCLAIMER
Given that even in the good case where you know for real the status you cannot know if the email has been received on the other end, nor how much time will it take, I'm not sure how useful such a construction would be. It'd certainly be fun to program, but I doubt it'd be really useful, maybe just some eye candy with standard email disclaimers (emails can be lost in transit, if it fails try again, leave sometime before retrying) would be enough.
I think the best option here is by estimating the time. You can test how much time some 10MB mails takes to be sent, to know the receiving speed of you SMTP server. With that information you can estimate transfer time of any email based on its size, and give your client some visual distraction based on that.
If you email process can send back information, then it may to possible to update a progress bar or progress text with the messages.
This is similiar to the way Wordpress upgrades/installs work. As the process is completed, text is displaying telling each step: "Downloading xxxx.xxx.xxx", "Deactivating Plugin", "Installing Plugin", "Attempting Reactivation", Reactivation successful": something similar. You would need a listener on the client side and a sender of messages on the server: as the script executes, it sends back messages to the client.
As said before, this can only realistically go as far as your server. You can signify if the mail left your server successfully, but without some sort of email reciever conformation step, I think that is as far as you can go.
I gues there us a chance to complete it, but can't be sure that this solution is done already by someone.
My thoughts:
As I know you can work with socket in non-blocking mode stream_set_blocking()
then you could try to use that approach to send emails via that non-blocking socket.