How does GitHub 'Reply by Email' work? - php

I notice that a lot of websites like Facebook and GitHub allow you to reply to an email notification which then posts the reply back to the application using a unique Reply-To address. How does this work on the back-end? I searched a lot but, only found that people were using unique Reply-To addresses. That's understandable but, what do they use to receive these emails? Do these companies set up email servers? I am trying to build this using PHP.

A common method is to set unique message ID's in the outgoing email and then looking at the In-Reply-To header to see which email this was in reply to. That lets you match up your server application's messaging system to emails. For example, if you send an email that represents a help desk ticket with ID 1234, the Message-ID could be something like
ticket-1234#myserver
Then, in email clients that work nicely (I'm looking at you Android), when you hit Reply, the reply has the header In-Reply-To: ticket-1234#mysever. You can go further by adding security tokens to ensure people can't forge messages (e.g. ticket-1234-hf29e9f2gf2e9fh29f#myserver). That security token is generated on the server when you send your first message and is then confirmed in the reply.
This normally works but can cause real headaches when email clients don't behave as they should!

This is how GitLab manages emails by using an identifier in the email address itself and catching it when the user replies. Although it is not relevant to any scripting language like PHP and uses server configs, this is what backend servers do to support reply by email functionality.

You have to set up a mail server to receive mail answers.
SIEVE filters on a IMAP server could be use to make some actions when a certain filter is detected.
But you can't only use PHP to make that type of system.

Related

Sending webforms: envelope sender not allowed

I have a website with a webform which users can use to contact a company. The webform internally creates an email in PHP using PHPMailer and is sending this email via SMTP to the company.
The company has a customer-management-system which identifies the user by looking at the sender of the email. Which means I couldn't send the email from the form from "form#example.com" to "customer-relations#example.com", but need to send it from "customeremail#customerdomain.com" to "customer-relations#example.com".
This worked for some years now, but since some time, we get the error-message:
"envelope sender not allowed customeremail#customerdomain.com"
for example from emails from #gmail.com. Other domains still work.
I understand that it is not good practice to "fake" the sender of the email to make the identification of the customer-management-system work. The developer of the customer-management-systems are not able to offer a solution yet (no comment on that...), so perhaps there are any ideas here which we could try to make this work?

Specify the "send via"- or "on behalf of"-value in Mandrill

I'm using Mandrill to send E-Mails in my PHP Project and integrated it via the API. So far so good E-Mails go out and arrive their recipient, but something bothers me about the missing SPF and DKIM entries.
When the E-Mails are opened in outlook the "on behalf of" issue occurs (FAQ from mandrills KB). But I can't fix this, since too many of our customers do not have the necessary skills/ access-rights to create a SPF entry for their domain, so we learned to live with that.
We verified our own domain at mandrill to use it as custom sending-domain to get rid of the
from: reallyLongString#mandrillapp.com on behalf of customerName#customerDomain.com
and exchange it with
from: mailbot#ourDomain.com on behalf of customerName#customerDomain.com
but somehow I can't get this to work!
I cannot find an option to set "mailbot" as sender. Even worse, Mandrill makes up a phantasy e-mail-address consisting of customerName#ourDomain.com. If some customer gets the idea to send to this address we've got a disaster upcoming. Also the API does not specify anything like that in the "Messages"-Section.
How can I configure mandrill to send E-Mails with a from-field appearing in outlook like this:
mailbot#ourDomain.com on behalf of customerName#customerDomain.com
? Really cannot find anything in the docs or the web. Thanks in advance!
As Sanuel Jackson already indicated, there is no way to do this WITHOUT doing the whole certification process of creating a SPF entry.
Also confirmed by Mandrill support (which was quite fast AND competent in responding)
I'm now sending with a proper reply-to address and hope, that our customer's customers ignore the funky e-mail adresses... In case they do mind them, our customers are free to engage us regarding a SPF-entry ;-)

How to sign my email messages sent via PHP with DKIM3?

My website example1.com is hosted on host.example2.com and when I send an email message via PHP mail() function from example1.com. It always has a 'via' host.example2.com stamp in Gmail when people receive the message.
I found this: http://support.google.com/mail/bin/answer.py?hl=en&ctx=mail&answer=1311182
Seems I need to:
Use an SPF record - which I have done, and it's now correctly showing
"Received-SPF: pass" in the email header.
Sign my messages by DKIM3 to be authenticated as truly from example1.com
And I scoured through http://www.dkim.org/ to find nothing about how to do it in PHP.
Any idea how I can use DKIM3 for my email messages sent via PHP mail()? Thanks!
http://php-dkim.sourceforge.net/ seems to be a PHP implementation of DKIM. The download contains a PHP library and detailed documentation.
Note that Gmail may not immediate stop displaying the "via" thing even if you implement DKIM. Google seems to use other heuristics to decide when to show "via" and when not to show it, and they're rather reluctant to disclose exactly what you need to do. But DKIM will go a long way toward assuring Google that you're not a spammer.

how to receive and validate incoming mail for web based mails in php

We are developing a email web site.but we are facing problem in receiving and validating the mail.i have the following doubts.can you please help me in clarifying these???
one more important thing is we are not using squrrelmail, qmail etc.
how do we receive emails for users in email web site?
do we save all the received emails in admin's mail box or in database as per the username
(my idea on email web site is,all the incoming mail are stored in admin's mail box and after the email mail is stored in database,and then the mail deleted in admin's mail box.Is it correct.if not how to store the emails in database directly in web site)
what is the technique behind the receiving mail???i think there are various techniques like email piping etc.
is there any special process of creating users for email web site,i mean do we need to create mailbox(i think mail account) for each user at the time of registration.if we need to create mail box for user,can we create it with imap_createmailbox() function.
are the users gmail,yahoomail etc are accessig database or their mail accounts at the time their login??
can we do all these things with imap functions in php??
There are many different solutions to this problem, polling existing servers, adding scripts to run when a message is received or using a gateway like CloudMailin. I wrote a blog post relating to this (it's for rails but almost all applies to php too).
The other problems almost all span from how you setup the first thing. In many cases you could just log the emails directly to your database and retrive them based on the recipient address. I think you need to explain exactly what you want to do with the email? Are you just providing email hosting for your users or are you providing an additional service? If you're just providing hosting then there are simpler approaches available.

PHP - Send email from other domain without being spam!

this was ask over and over and still no good solution!
When someone sends an email using php and placing another domain in "from" it will end up in spam.
Solutions normally are:
- Use your "from" and place the domain you want in the "reply-to";
- Have your domain whitelisted by main mail services.
The 1st its not really a solution and I was never able to make 2nd, because its impossible to reach hotmail.com, yahoo.com, etc..
I see lots of sites today having the option to email article to someone from the user email. How can I achieve this?
Thx,
Telmo Cardoso
When someone sends an email using php
and placing another domain in "from"
it will end up in spam.
This is not neccessarily true.
Check which mail servers identify your message as spam. Also check with your hosting company for their preferred method to send out mail.
Try to be straightforward with your message. Offer the users a short textarea (with your default masage), which they can change and customize. Also give the possibility to enter real name of the participants with their e-mail addresses.
Just be senible and your messas will go thru.
Send the email from your webserver and add a reply-to header like you have mentioned.
Make sure you have SPF setup for your server to help get yourself into the gMail, Live Mail and Yahoo accounts.
A nice and cheap alternative is to send your emails via Amazon SES to avoid having to warm your own IPs etc.
I would go with the Amazon SES (or a similar service) and leave the worrying about getting the server setup right to the experts. Make ensuring deliverability someone elses problem.
This article is a nice starting point:
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
The problem is related to the header of the email. not neccessarily the 'from' address domain. Some spam filters (i.e. cox.net incoming spam filters) will perform a reverse lookup on the IP address that the email came from. If the domain name returned on the reverse lookup is not the domain name of the sending address. Then they will liekly mark it as spam.

Categories