简体   繁体   中英

Is it possible to reply to PHP mail to have a server run a script?

Is it possible to send out an email from PHP mail, then reply to the message, and have the text from the reply message imported into the php script as a variable? If that is not posssible, how would I be able to send an email to my server to run a script based off the text in the body of my email?

You have two choices:

  1. You could have the mail server run the script when it receives an email. How you do this depends on what mail server you use.

  2. Run a script/program periodically (using a cron job or equivalent) to fetch mail from the server (using pop3 or equivalent) and process each email as necessary.

The details depend a lot on exactly what you're trying to do and what platform you are running on.

Not directly. PHP does not actually send the mail unless you're using a library that has implemented the smtp protocol. There are libraries like phpMailer and pear:mail that do this, but typically people use the mail() call which dumps the mail off to an installed MTA like sendmail or postfix to do the actual work. Furthermore, the replied to mail has to be received by a valid mail server. In other words: php is not an mta.

It is certainly possible to set the mail server up to support POP or IMAP and use a PHP library to fetch the messages using those protocols.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM