Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change smtp port from 25 to 587?

Tags:

php

email

port

My ISP have blocked port 25 for sending mails from PHP, and instead have allowed port 587 or 465 to be used. how do i force php mail function to use port 587 instead of default 25? BTW : i am on OSX 10.6.6 using MAMP PRO

UPDATE : i tried changing the settings in php.ini to this

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 587

as i am on mac i don't think this can be the solution for me, and it is not working after i tried. it gives me following error message.

May  6 20:32:25 Ibrahim-Armars-MacBook-Pro postfix/smtp[2822]: connect to alt2.aspmx.l.google.com[74.125.159.27]:25: Operation timed out
May  6 20:32:25 Ibrahim-Armars-MacBook-Pro postfix/smtp[2823]: connect to alt2.aspmx.l.google.com[74.125.159.27]:25: Operation timed out
May  6 20:32:25 Ibrahim-Armars-MacBook-Pro postfix/smtp[2827]: connect to alt2.aspmx.l.google.com[74.125.159.27]:25: Operation timed out
May  6 20:32:25 Ibrahim-Armars-MacBook-Pro postfix/smtp[2825]: connect to alt2.aspmx.l.google.com[74.125.159.27]:25: Operation timed out
May  6 20:32:25 Ibrahim-Armars-MacBook-Pro postfix/smtp[2828]: connect to alt2.aspmx.l.google.com[74.125.159.27]:25: Operation timed out

you see it is still trying to connect via port 25? how do i change it in mac?

like image 983
Ibrahim Azhar Armar Avatar asked May 06 '11 14:05

Ibrahim Azhar Armar


1 Answers

Changing smtp_port only affects how mail() interacts with the server specified by SMTP setting. This isn't the issue. The issue is that:

  1. You are using your local machine as the SMTP server - AND
  2. Your ISP is blocking your local SMTP server (postfix) from relaying messages out to Gmail

First, read this thread. It discusses the same exact issue. The upshot is that you need to use a different mail server, preferably your ISPs mail server. What server and port does your ISP tell you to use for outbound mail if you want to use their Email services? You should be able to use this from your PHP running locally just like you would an email client like Thundebird - and you will be able to send to Gmail.

like image 128
AJ. Avatar answered Oct 25 '22 00:10

AJ.