I'm a PHP web developer. I need to set up my Ubuntu workstation (10.04.1 LTS) so that I can debug mail without it really going out to the WWW. So, I need to work with pretend domains like from.com and to.com. What is the fastest, shortest, easiest way that I can configure PHP to enable outgoing mail that stays only on my server, and then receive this mail using Mozilla Thunderbird?
|
feedback
|
|
Ubuntu comes with Sendmail by default, which can cause you to rip your hair out in my opinion. Postfix appears somewhat easier to configure. So, I did this:
The procmail will install Postfix by default. When the Postfix install runs, it will automatically show a blue screen where you need to select the install type. Choose Local Only. Next, edit /etc/postfix/main.cf and set mydestination parameter so that it contains a comma-delimited list of domains for your from and to, such as:
Next, edit /etc/aliases as root. So, if your user account in Ubuntu (the one you login with) is dev, and you want to send test mail as a programmer to jack@to.com, then your /etc/aliases would have this entry in it somewhere:
Once done, as root, run this command:
Now bounce your mail server as root:
Now when your PHP code sends a message of any address at from.com (doesn't matter which) to jack@to.com, your mail server will automatically put it into a file /var/spool/mail/dev. So, how to go read it? Well, I don't particularly like Evolution over Thunderbird, but it seemed to be more configurable for this task. I opened it up and added a new account. In there, I added dev@localhost and then chose Local Delivery. On that file path, I chose /var/spool/mail/dev. On sending mail, I chose Sendmail even though I don't have that installed anymore. I mean, I'm not caring about sending mail back from my inbox to the mail server, just receiving it so that I can debug the messages and ensure the mail will work properly. However, you can choose a different outgoing mail server config if you want. Anyway, from there, I clicked OK, and then I clicked the Send/Receive button to download new messages. At that point, I could send messages out of PHP to an account jack@to.com, and pick them up with Evolution quite easily. | |||
|
feedback
|