2

I am trying to send an email to my thunderbird or google acount using PHP from a local server in Ubuntu. I have used the mail() function in PHP.

I have done some research and apparently you can not send an email from the local server unless you install an email system. So I went with postfix and installed it:

sudo apt-get install postfix

For the configuration I chose Satellite. I don't know how to proceed from here.

What should I type for System mail name, is localhost correct?

I left SMTP relay host and Root and postmaster mail recipient: blank.

I am very much confused and could not find any step by step tutorial. I would appreciate any help and some clarification on how to finish the steps in postfix configuration.

Edit: I looked at this https://help.ubuntu.com/community/Postfix

But why System mail name: example.com and why we choose General type of mail configuration: Internet Site?

0

In short: choose Internet Site as a configuration and use fqdn for Mail System name (if you use localhost it will be classified as spam most likely).

Problem is, for some of the mail servers nowadays it will not be enough (for example, gmail tends to classify such configuration as spam).

What else will you need:

  • MX DNS record (a DNS record, that will point to appropriate IP as a Mail target for given domain - you can check it with host -t MX domain)
  • postconf -e "myhostname = [hosts fqdn]"
  • postconf -e "myorigin = \$myhostname"
  • You can do much more in term of configuration, but I've found out that that was the bare minimum for my LAMP stack to send mail via mail() correctly. – Marek Bettman Sep 15 '15 at 13:39
  • Thanks, would it work for both gmail and thunderbird? – Jack Sep 15 '15 at 13:41
  • What do you mean - gmail is a mail service, thunderbird is just email client. Thunderbird will work with any IMAP service. If you will see emails in gmail interface, then Thunderbird will work :) – Marek Bettman Sep 15 '15 at 13:44
  • The thing is I get an email as www-data@example.com in my gmail account using mail() function of php but when I change the email address to my company's email address which is set-up using windowslivemail (I get my emails through thunderbird in ubuntu) I don't see anything. – Jack Sep 15 '15 at 15:58
  • Yeap, totally correct - you don't want to anybody be able to spoof author like this. So generally most mail servers won't allow an email originating from one domain if from header disagrees. BUT, you can configure your postfix as a relay and tell it to authenticate with your work email which will have effect of emails seem to be originating from your work email. – Marek Bettman Sep 15 '15 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.