As i'm knowing just about PHP and don't know at all about Mail Servers, what i want to know here is:
How can i get the "Replied" emails (from the receivers) for the mails i've send (by using PHP, with a address like xxxxxxx#gmail.com)
Does it need to setup my own Mail Server?
Unless using own Mail Server, is there any other easy way?
Honestly i'm not well understanding over IMAP or Email Protocols. Doing setup my own IMAP Server is far worse. Can it be done simply with a Web Hosting which supporting IMAP protocol? Or do i need to setup manually out from the start?
To be brief, i need a simple guide.
You only need a mail server if you don't already have a place where those reply-tos end up. Which adress are you sending them as? Where would you fetch the emails for those adress? You can ask PHP to log into any mail server that you'd fetch your emails from manually as well, so there shouldn't be a problem. But maybe I'm not getting you right.
Simply put the reply address to an email you own. For the example you gave to work, you would need to have the xxxx#gmail.com account.
Most people use something along the lines of mailer#youdomain.com, ans then create an account for that on their ma8lserver.
If you want to use your own domain, you don't need to run your own mailserver. Gmail, hotmail, and others have services that let you use their mailservers for your fomain, for free.
Related
So I downloaded the Free Edition of MAMP free, and found out that it doesn't initially allow sending mail through PHP.
My question is very simple. What is the best and easiest way to enable it?
Thanks in advance.
This is probably not really the answer you are looking for, but if you're set on sending emails try a program like https://github.com/PHPMailer/PHPMailer
it will enable you to send emails through an SMTP server (like gmail). It will make sure your emails get delivered while working on localhost. When going live you could tell it to use PHP mail in the config (which is actually never recommended because of the spam factor and limited functionality).
That being said, while on localhost it shouldn't be necessary to send emails. Being that localhost usually implies a staging/development surrounding. What I like to do is output the to be sent email to my error log.
http://us3.php.net/manual/en/function.error-log.php
You can instantly tell how it looks and you get confirmation that your script has run that part.
It is not possible for you to send email from local server like WAMP,XAMP.
I would like to have a server that is able to receive emails. Then I want to use PHP to program the way the emails are shown to the users. Can I do it purely with PHP? I mean, it is not a problem to send emails from PHP but I do not know if I can receive emails by PHP? (In a way PHP receives POST requests).
ADDED
As a response to the first answer, I would like to specify that it looks like I need an SMTP server. I want to be able to communicate with the SMTP server in a programmatic way. For example, I want to have a possibility to "tell" to the SMTP server to create a new e-mail address. I also need to know where incoming emails stored and in what format. For example, how I can extract the "sender", "cc", "bcc" from the file corresponding to the received mail.
would like to have a sever that is able to receive e-mails.
If you are writing it from scratch then you'll need the specification for SMTP. I would advise very strongly against this. SMTP servers are hard to write, and there are several really good open source solutions out there.
My understanding of PHP is that it does very poorly when it comes to multithreading, so it probably isn't a good solution for this problem.
Than I want to use PHP to program the way the mails are shown to the users
Servers that receive mails do not typically show them to users. They usually store them in a standard way (such as Maildir or mbox) which other software (such as a local email client or an IMAP server) accesses.
The job of showing email to a user is belongs to email clients. Web based PHP web mail software includes SquirrelMail and RoundCube. AFAIK they both act as IMAP clients. See the IMAP specification.
As a response to the first answer, I would like to specify that it looks like I need a SMTP servers. I want to be able to communicate with the SMTP server in a programmatic way. For example, I want to have a possibility to "tell" to the SMTP server to create a new e-mail address.
Pick an SMTP server that runs on your OS. Read the instructions to find out how to configure delivery and accepted addresses. It usually comes down to manipulating text files.
I also need to know where incoming mails stored and in what format. For example, how I can extract the "sender", "cc", "bcc" from the file corresponding to the received mail.
Again. See the manual for the mailserver. Most will give you options about where to store the data and in what format.
Then you just need to decide if you are going to get PHP to dig into those directly, or use an IMAP server in between.
No, that is not easily possible. PHP is made for (stateless) http protocol, while a mail is sent in a conversation that is built up from various requests and responses.
It is possible to parse and process mails using PHP, but I would recommend installing a mailbox that you can read from PHP using POP3. Then, your PHP application can show and process mails from that mailbox.
I'm working on a website that allows you to send emails without registering, and without specifying a sender. You enter the recipient's address, subject, body and send. My problem is sending the message. What I'm trying to achieve:
User clicked send -> Subject,recipient,body sent to PHP -> Server validates the information -> Server creates a random email account -> Server sends the email through the random account created -> Server deletes the account
I'm stuck at the random email account creation step. How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
I googl'd the hell out of this issue and I can't find an answer.
Thanks!
BTW
I'm using Apache to "host" on my own Ubuntu
How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
The way to create E-Mail accounts varies wildly from server software to server software, and is usually not possible from within PHP.
Depending on your server's configuration, though, that might not be necessary: If you set up a catch all address for a domain, many server configurations will allow you to send out mails from any E-Mail on that domain (e.g. 123456789#example.com). Any responses will then go to that catch-all mailbox, the contents of which you will probably want to discard.
You have to realize, though, that this is exactly how spam providers operate. Extreme caution is advised if you don't want to end up on all sorts of spam blacklists.
I don't believe you can create accounts or email accounts on a server, using PHP, as this supersedes PHP's permission level. Sending emails this way is a good way to get your server banned, FYI. Also, if you insist on sending emails like this, why not just specify a dummy From: email address? It would essentially be the same thing as creating a dummy account anyhow.
You may also want to use the -f switch, for PHP's mail(). See php.net/manual/en/function.mail.php
I'm coding in PHP w/ CodeIgniter and I'd like to test some of the features in my app that send emails.
For some reason, I couldn't send emails through my email account in my local server (XAMPP), and I also don't want some SPAM filter to think I'm spamming while I'm testing.
So is there any email service that I can use for testing purposes? preferably one that doesn't enforce SSL, since I have problems getting that to work on my local server.
Appreciate your help.
As long as you're not sending out dozens or hundreds of test E-Mails, use whatever your everyday E-Mail provider is (e.g. GMail). Set the SMTP server of your mailing function to point to Google's. (I think SSL is optional with GMail, but I may be wrong.)
If your mailing library doesn't support using an external SMTP server, switch to a different one. But I think CodeIgniter has you covered there.
If you just want to test the application functionality, check out Papercut. This utility simulates the sending of email without having to set up a mail server, works great!
edit: had wrong link.
I like to set up a test SMTP service on my development machine and just send to that. There are several good options listed under this question.
I have some problems with the email system for CodeIgniter:
First, the emails I send out (registration, confirmations) are getting caught in standard spam filters in gmail and other mail clients. How do I get around this? How do companies like Facebook get their emails through consistently?
Second, the mailer is working locally but once we deploy it it no longer runs (doesn't send emails) but all the other forms run just fine. Anyone ever run into a problem like this?
Thanks for all the help!
I can't really answer your first question - it's not specific to CodeIgniter. You just need to make sure your email doesn't look like spam. In short - there's no way of guaranteeing your e-mail will not end up in a spam filter.
As for the second question, I expect your production server needs to be configured properly for email. You probably need to configure CodeIgniter to send email properly. I would suggest setting up an SMTP server (or using an existing one) rather than using the standard PHP mail which I think CodeIgniter uses by default.
Regarding spam, most organisations are very secretive about how they prevent spam (not wanting to publish information which helps the spammers) and in some cases they don't actually know - an obvious examlpe of this is bayesian filtering - but, for example, hotmail use a completely unaccountable army of volunteers to manually classify emails.
Do and get a copy of spamassassin and try to reverse engineer how the standard rules work. Obvious things to check are:
1) AVOIDING LOTS OF CAPITALS
2) don't mention the 'V' word
3) make sure you've got a current and restrictive SPF 1.0 policy published
4) make sure your sending from an address which has A and PTR DNS records
5) Do provide a reply-to and from email address which use your domain in the address
the mailer is working locally but once we deploy it it no longer runs
doesn't send emails
Which? These are 2 totally seperate things. If the code is falling over (if so why have you not provided the error details) then its likely a PHP version issue or a problem with the connection to the MTA (or the PHP mail config).
The latter is a problem with the MTA itself.
99.9% of problems reported as PHP mail failures have nothing to do with PHP and are problems with the MTA.
Enabled detailled error reporting for your MTA and see where it is failing.
C.
You may have to configure the email on your server differently than your local development environment. I've had to in the past.
There are two basic ways that PHP can send mail:
Via a UNIX program called "sendmail" (only on non-Windows servers and only if it is installed - check with your hosting provider)
Via a SMTP server.
If you've configured CodeIgniter to use SENDMAIL, check to ensure that the Sendmail path is correct. Your hosting provider usually provides this somewhere in their online documentation.
If you're using SMTP, you need to make sure that your server can contact the SMTP server. You can do this by logging into the server via SSH and typing "telnet your.smtpserver.com 25". If you get an error message about not being able to connect, you know you have a problem with your hosting provider connecting to your mail server.
I've been able to diagnose this problem by enabling logging on my production server (http://bit.ly/4pprd6) and adding log_message('error', $this->email->print_debugger()) right after I attempt to send a message.