Creating SMTP Account and Receiving mail using PHP - php

I was wondering if during the time of my User Registration for my site, I can create an SMTP account something like : username#mydomain.com for that user using PHP?
And also, some method of receiving/fetching the mails using PHP into my DB so that it can act as a mail client as well?
The closest answer I could find was using something like "procmail" or some service like : "http://www.cloudmailin.com/"
However, is there no other method to do it?
For example, when we send a mail at someuser#facebook.com it goes directly to his message box. How is this happening?

Another way to do this is to setup your mail server to accept mail to *#yourdomain.com, and forward all incoming messages to your PHP script which will parse each incoming message, update your DB, etc. For more info on how to set this up, see: http://harrybailey.com/2009/02/send-or-pipe-an-email-to-a-php-script/

Related

Cordova/Ionic: How to send Mail

is there a possibility to send a email in Ionic/Cordova, within my App. I looked at the EmailComposer Plugin, but this seems to just open my default email program. Can Ionic somehow handle php, and whe so, how?
Or if this is not possible, can I send Data, to my Website and store it there?
You can't directly send email using php through phonegap. You need to host php in live server, then send data from your app to server's php script and send mail.
If you want to store data in your server(website) you can write some script (in php or asp etc.) to save data into database and call those scripts using AJAX. You'll get tons of materials and tutorials for doing this. These are hints how you can achieve the functionality you wanted, search them and learn them.
use jquery,php mail function to send emails
mail('$sender','$receiver','$subject','$message');
or
Use AJAX to store data on mySQL DB

Tracking of email

Basically i want to make an app which will check that user has opened the sent mail or not
just like the script of "[http://www.readnotify.com][1]" like we have to just add
readnotify.com after the receivers email address before sending the email.
i have read that it is done by adding the img tag with very small size(1*1) in the email
<img src="http:/yoursite.com"/>
something like the above code and we got even the geolocation of the receiver.
How are they doing this behind the scenes??
means what they are doing in their PHP code ??
Image is generated by your script, which reads $_SERVER variables ( http://php.net/manual/en/reserved.variables.server.php ). Then you can get clients IP and so on. But rest assured, that most of mail clients do not open images unless user permits it beforehand.

How to affect a PHP program / mysql database from an email response

I am trying to work out how to do something. It must be possible - I've seen something similar done in multiple systems (Twitter, facebook etc.)
The basic thing I want to do is - someone leaves a comment on my website. The comment goes to my email, as well as to my MySql database. I then reply directly on my email. The reply is saved to the database, and auto-approves the user's comment.
I can't work out how to speak to my MySql / PHP system directly from an email. Also - I can't work out how to set up the inboxes?
I am guessing that I'd need to set up mailserver rules so that emails sent to xxxx-response#mydomain.com are actually redirected to a php script, where xxxx is an identifier of the original comment?
Thanks for any light that you can shed...
Assuming you're on a unix system, you could set up an account for receiving the mail, e.g. "fred", and use a .forward in fred's home directory to pipe emails to your php script. e.g.
.forward:
|"/usr/bin/php /path/to/your/script.php"
which will invoke your script anytime an email arrives in fred's mailbox.
You can't 'talk to mysql from an email'. An email is a passive piece of text, nothing that can take actions.
The solution is based on something like this:
You have an email account and poll that accounts Inbox by a php script in a periodical manner, by using wget or similar in combinition with a crontab entry. You can also create an event driven approach, but that is more complex and does not really offer advantages. For all messages found inside that inbox you check if it matches any previous entry in the database. You can do that since you have access to the messages headers and body (the text) by php. That is all you need. Typically the connection between two messages is done by evaluating the 'In-reply-to' header that is set by email programs when you press the reply button. It is like a reference.
The access to the accounts inbox is done by standard mail access protocols, typically pop3 or better imap4. When the mail server is not on the same system then abviously you want to add ssl encryption too. php's imap extension is a very good start for implementing such a client, it supports several protocols.

to ban sending html email from server

i am building up an email server. Is there any way that i can ban sending emails from my server in html format? Also if the user uses another smtp server like gmail to send email in html format but hosts the page on my site, is there any way that i can ban it? I just want to know whether its possible? I am using php for coding.
PHP is fit for creating a front end for a webmailer.
If you can generally bann HTML mails depends on the mail server you use.
BUT:
As long as any user input is processed by one of your scripts you can do it.
If you implement skripts that use mail() or similar functions you can always send plain text mails and/or filter html text from the user input.
If your script uses another smtp server you can do filter the mail before you pass it on to the smtp server.

What can I use instead of TFMail for a form-mail script?

TFMail was a popular PERL CGI Form Mail script at one time. So far it has served our purposes. It is very easy to set up and configure.
Unfortunately, it only has basic functionality. It works well when you want users to fill in a form and have the result emailed to a specified email address.
Can someone recommend a script ( maybe a PHP script ) that I can use to replace TFMail?
Here's the functionality that I like in TFMail:
Set up an HTML form and point the action at the script
The result of the form gets sent via email
Specify the recipient of the email
Create a template for the email sent to the recipient
Create a emplate for the email sent to the
submitter
Create a template for the
log file
Allow file attachments
Redirect to a thank-you/confirmation page
There are tons. If you use a framework, it will have something, most likely. If not, there is HTML::MIME, Zend_Mail (can be used with or w/o Zend), and many more just a google search away. In the late 90's, it seemed that everyone starting out in something like Perl or PHP would write a mailer as a right-of-passage or something so there are a million of them out there.
http://htmlmimemail.tuxfamily.org/
http://www.electrictoolbox.com/sending-email-zend-mail/
etc...
(Creating our own frameworks is the new right-of-passage, I think.)

Categories