How to change postfix port from 25 to 587

emailpostfixsmtp

I am total noob about Unix and CLI. after googling for almost 6 hours I came to know I should be editing postfix port from 25 to 587 for PHP mail() function to work. and here is the solution I got http://www.linuxmail.info/postfix-change-port/ but I am not sure how to change it. as already said I am a noob. any help regarding this will be appreciated.

UPDATE1 :

grawity solution gives me the following error.

May  7 00:42:39 Ibrahim-Armars-MacBook-Pro postfix/pickup[4169]: DE2073F07C1: uid=501 from=<azhararmar>
May  7 00:42:39 Ibrahim-Armars-MacBook-Pro postfix/master[4185]: fatal: open lock file pid/master.pid: unable to set exclusive lock: Resource temporarily unavailable
May  7 00:42:39 Ibrahim-Armars-MacBook-Pro postfix/cleanup[4177]: DE2073F07C1: message-id=<20110506191239.DE2073F07C1@Ibrahim-Armars-MacBook-Pro.local>
May  7 00:42:39 Ibrahim-Armars-MacBook-Pro postfix/qmgr[4168]: DE2073F07C1: from=<azhararmar@Ibrahim-Armars-MacBook-Pro.local>, size=525, nrcpt=1 (queue active)
May  7 00:42:40 Ibrahim-Armars-MacBook-Pro postfix/smtp[4179]: DE2073F07C1: to=<azhar@iarmar.com>, relay=smtp.gmail.com[74.125.155.109]:587, delay=0.8, delays=0.01/0/0.79/0, dsn=4.7.5, status=deferred (TLS is required, but our TLS engine is unavailable)
May  7 00:42:41 Ibrahim-Armars-MacBook-Pro postfix/pickup[4169]: 5F2FC3F07C4: uid=501 from=<azhararmar>
May  7 00:42:41 Ibrahim-Armars-MacBook-Pro postfix/cleanup[4177]: 5F2FC3F07C4: message-id=<20110506191241.5F2FC3F07C4@Ibrahim-Armars-MacBook-Pro.local>
May  7 00:42:41 Ibrahim-Armars-MacBook-Pro postfix/qmgr[4168]: 5F2FC3F07C4: from=<azhararmar@Ibrahim-Armars-MacBook-Pro.local>, size=525, nrcpt=1 (queue active)
May  7 00:42:42 Ibrahim-Armars-MacBook-Pro postfix/smtp[4179]: 5F2FC3F07C4: to=<azhar@iarmar.com>, relay=smtp.gmail.com[74.125.155.109]:587, delay=0.79, delays=0.01/0/0.78/0, dsn=4.7.5, status=deferred (TLS is required, but our TLS engine is unavailable)
May  7 00:42:50 Ibrahim-Armars-MacBook-Pro postfix/master[4190]: fatal: open lock file pid/master.pid: unable to set exclusive lock: Resource temporarily unavailable

UPDATE 2 :

May  7 01:10:02 Ibrahim-Armars-MacBook-Pro postfix/master[4472]: fatal: open lock file pid/master.pid: unable to set exclusive lock: Resource temporarily unavailable
May  7 01:10:02 Ibrahim-Armars-MacBook-Pro postfix/pickup[4419]: 357F73F090F: uid=501 from=<azhararmar>
May  7 01:10:02 Ibrahim-Armars-MacBook-Pro postfix/cleanup[4430]: 357F73F090F: message-id=<20110506194002.357F73F090F@Ibrahim-Armars-MacBook-Pro.local>
May  7 01:10:02 Ibrahim-Armars-MacBook-Pro postfix/qmgr[4420]: 357F73F090F: from=<azhararmar@Ibrahim-Armars-MacBook-Pro.local>, size=525, nrcpt=1 (queue active)
May  7 01:10:03 Ibrahim-Armars-MacBook-Pro postfix/smtp[4448]: certificate verification failed for smtp.gmail.com[74.125.155.109]:587: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority

Best Answer

According to your comments on other answers, you need to configure Postfix to use Gmail as a relay host. There are many tutorials on the Internet for this; here's a quick version.

Note: With this configuration, all mail must be sent using your Gmail address as "From".

  1. Undo all your changes to master.cf.

  2. In main.cf, add these settings:

    # This tells Postfix to hand off all messages to Gmail, and never do direct delivery.
    relayhost = [smtp.gmail.com]:587
    
    # This enables TLS (SMTPS) certificate verification, because Gmail has a valid one.
    smtp_tls_security_level = verify
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache
    
    # This tells Postfix to provide the username/password when Gmail asks for one.
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    
  3. In /etc/postfix/sasl_passwd, add your Gmail username and password, like this:

    [smtp.gmail.com]:587    user@gmail.com:mypassword
    
  4. Compile the sasl_passwd file into a database:

    postmap /etc/postfix/sasl_passwd
    
  5. Finally reload Postfix's main configuration:

    postfix reload
    
Related Question