I'm in need of setting up an auto-response from an email account that I control, based on trigger words within the body of the email. But also, it needs to add/delete rows from a database table based on trigger words sent to this email account (that belongs to my site) and it needs to create a topic, in some cases, within a forum, if sent to a different email address (but on the same server). I know PHP to be able to do this, but not really sure how to trigger a PHP script to be executed when an email gets sent to a specific email address account that I control. Or if there is another solution to accomplish this, please let me know.
This is basically an inquiry on how to accomplish something like this, based on an email sent to a specific email address on my server with words like: "Join", "Leave", "Set Mail", "Set Digest", etc. etc.
There will be another email address account set aside that will need to send those subscribers in the database, the same exact email (Mass Send). This is for a CDB-L ListServ. Kind of old school I suppose, but we want to transfer this ability to our server, since these old school methods still work today and is very much active.
Curious on security issues, what type of server software I'll need and just a basic approach on how to set something like this up.
You can alias your email address directly to a php script if you run your own mail server (on linux this would just be in the /etc/alias file or equivalent where the target was your php script instead of an email address) eg http://www.topwebhosts.org/bbs/board.php?bo_table=server_mgmt&wr_id=73
If not, then your only real choice is to set up a php process that checks an email address for mail every x minutes.
I have used both these methods over the years to great success
You can walk through emails with PHP's IMAP functions and undertake action (based on conditions/content). More info.
Related
I've written a small script that simply (as simple as email can be) downloads emails so I can play with them later. The part that I don't seem to be able to grasp quite perfectly is that the msgno can (will) change when new emails get added or emails get deleted. Okay, that's fine, but then for the uid, this also can (will) change when emails are moved from folder to folder.
So in PHP, for example, when I execute imap_search and get a list of msgnos or uids, how do I reliably use these to get emails for a changing email box? In this example, there are multiple Outlook clients connected to this mailbox with many rules for auto-moving emails from/to specific people, etc. that's bound to move emails after I've already gotten the ID's, and before I actually get to processing that email.
In this case, what do you do? I would very much so like to avoid the email just "not existing" by the time I get to it, or worse, the ID in that IMAP mailbox be resigned to a new email.
I have to set up an email sending solution, and I haven't yet figured out the best way to do this, I hope you have some ideas. I would like to achieve the following:
Have a central email address like mailinglist#mysite.com.
Behind this list there is a database of email addresses. I would like to be able to extend this list through an API. For example if a new user registers on my site, I want to add them to the list. Or if someone unsubscribes, I want to remove him from the list.
On my website I will place a button, and if the user clicks it their email client opens with the central address prepopulated.
If they send an email to this address, everyone will recieve it who is on the list.
If someone replies also everybody will recieve it.
(The application is written in PHP (Laravel framework) if that is important).
Do you know of any service where I can set up this kind of "mailing list", preferrably for free? (It would have a few hundred members, sending a somewhere around 30-100 emails a month.)
I guess you'll need root access to your (linux) webserver - then you can hook Sympa (read "list of features") into your MailTransportAgent (MTA) (postfix, exim) or whatever.
I am building a basic support request system where the customer can log in and ask a question and an admin can go in and reply and it will set the status to "Responded" and e-mail the customer to let them know someone has responded.
My question is.. I have a "comments" section which is a log of the interaction between the admin and the customer. If I e-mail the customer the initial response from the admin, then I have a feeling they will just hit "Reply" from their email and start communicating through there, and the logs won't be stored.
I could either e-mail the customer and say "Log in to view the response", or maybe if the customer does hit reply I can somehow track it and insert that in the comments table like they did it from the website. If that is even possible?
Just wondering if there is a standard way to do this and any suggestions you may have.
Thanks!
When sending the email to the user you can have it sent from an email address created for that specific ticket. Something that can identify it with your email system to help you route it back to the php ticketing system.
support(ticketnumber)#domain
support12345#mydomain.com
Then it depends on your email server how to go from there.
There are several useful tips at this question that may help or get your started.
How to get email and their attachments from PHP
If you want their reply to be automatically inserted into the DB, you'll have a assign a cron job in your server to run a php script to detect whether there's a reply from a customer (you need a table listing the customers' email and names.
Each time a customer uses the ticket system their email and name goes into this table).
You'll need to connect to your Inbox too via imap or SMTP, and there are scripts to do this (phpmailer, swiftmailer, etc) and "walk" through each email and see if the sender email matches any in your customers table. Then so an INSERT to the comments table.
Anther way is to read through the emails each time the comments page is loaded, but this will cause the page to take longer to load. However, the data will always be more "real-time" compared to cron jobs.
You could use email piping (if your server supports it).
In the subject, you'd have a unique identifier which contains the ticket ID or something unique to the ticket. Example: "How do I eat food [Question: #1234]", where 1234 is the ticket ID.
In your control panel, you would set up an email forwarder to your email piping script.
This tutorial offers the basics to email piping, and I used it as the base for my piping script: http://www.damnsemicolon.com/php/parse-emails-in-php-with-email-piping-part-1
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.
Client asked this morning if we can provide a subscription service whereby:
Mail arives to a specific address on a cloud mail server with no procmail/maildrop possibilities
Cron runs Perl or PHP script on another server which checks for new mail and based on address mail purports to be from, does a subscriber look up, and forwards the email with any attachments to all subscribers along with an added unsubscribe link
Script deletes forwarded email
Mail server will have both IMAP and POP access, apparently.
// EDIT
Note that mail will be from 220+ governmental agencies/organizations. Users will use interface to specify which organizations they wish to receive forwards from. In order to run like a traditional mailing list we'd have to set up 200 mailing lists and then make an interface to handle subscriptions. The proposed interface will allow 1 - 200 subscriptions with a single opt-in confirmation email and a single opt-out interface.
// END EDIT
Client has been warned that header spoofing is child's play and that viral attachments are a serious concern and is willing to proceed nonetheless.
So, with the caveat that this is NOT an idea that I endorse what libraries have you used to accomplish this sort of task?
You do not mention what kind of mail server you are dealing with. Perl has Net::IMAP::Client and Net::POP3 to handle fetching mail.
For sending email using an SMTP server, there is Email::Sender or Net::SMTP or Net::SMTP::SSL.
At a minimum, you'll need an email account which you can use to send emails (this might be the original account that receives the messages).
In between fetching and sending, you can check for spam using Spam Assassin and for viruses using ClamAV.
I don't know why the original messages need to be deleted, but at the very least, I would log every single step in detail.
What you're describing is a mailing list. If at all possible, you should look into using one of the several existing software packages designed for managing such lists, such as majordomo, ezmlm or mailman, rather than trying to roll your own.