I was having a problem with some (not all) invitation emails not being sent, or not reaching their destination. I think the problem may lie within the _invite_send_invite function, specifically in the following line of code...
if ($success = user_mail($email, $subject, wordwrap($body, 72), "From: $from\r\nReply-To: $replyto")) {
My webserver is on a linux box, and I have read in the user_mail api documentation that on linux carriage returns should be "\n" and not "\r\n" or else problems may occur with email not reaching its destination. The user_mail function called in the above code is itself set to strip off any "\r", but it looks like it only strips them from the message body, and not from the header. Could this be the problem? As it is the header which is being set in the above code where \r\n appears, I tried removing the \r from the code, and I think the mails are all being received properly now, though it is hard for me to be sure. Can anyone confirm this for me? Thanks in advance for your help.
Comments
Comment #1
Nick Wilson commentedActually, the api doc says this:
which would suggest something else is the cause of your issue i thnk.
Comment #2
sja1 commentedHi, thanks for taking a look at this. I went back and looked at the api doc and you're right, it does say \r\n should be used in the header. So then I went to the php documentation of the mail() command, which is the command invoked by the user_mail function, and found the following documentation (http://es.php.net/manual/en/function.mail.php). The last "Note:" suggests that the \r\n could indeed be causing problems.
I also found this note googling for answers...
Comment #3
Nick Wilson commentedCan you tell us what MTA your system uses, and if using just \r is working for you?
Comment #4
sja1 commentedHi, it looks like my server is running qmail. I have modified my version of invite.module to use just \n, and mail is going out (put myself on BCC for a while to make sure). It seems like that has alleviated the problem of invitations not being received, because I haven't received any more complaints since making the change. But I can't be 100% sure as users don't always talk with the person they are inviting to ensure that their invitation has been received.
Comment #5
AjK commentedPersonally I would mark this "won't fix". The reason, you identified the fault and it's not Drupal which is RFC complient in this case. It's been identified that the MTA is the culpret not being RFC complient.
The work around you did worked for you but it's not a solution for Drupal. The real soution is "use a proper MTA that is complient". All I can suggest is a note in the README file about it. But we shouldn't remove the \r just bacause one MTA doesn't like it ;)