0

I want to send emails from my PHP web app. I know that it is possible because a couple of months ago, I had this "feature" on my system, then I started to use xampp and the feature disappeared.

I thought that when I come back to my local server and will use a local MySQL database and stuff like I used to before, I could send emails from my web apps again.

I updated my operating system from Mountain Lion to Mavericks (no idea whether this could be the main issue) and went back to local apache server also removing xampp. But I still can't send emails from my web app.

I changed the php.ini file that is in use so I can use the mail feature:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "/usr/sbin/sendmail -t -i"
kalafun
  • 3,512
  • 6
  • 35
  • 49
  • 2
    Do you actually have an SMTP server installed? – developerwjk Jan 15 '14 at 22:49
  • Could you please provide an example please ? I have apache james for testing also, but I dont recall that I had one the first time I was sending emails from my local server. – kalafun Jan 15 '14 at 22:55
  • Maybe you can use some lib PHPMailer, it's simple to use and you have many examples (google). – Miguel Q. Jan 15 '14 at 23:01
  • 2
    No example will help you if you don't have an SMTP server installed. Apache can't send email by itself. Needs an SMTP server. Although you might be able to use GMail as your SMTP server: http://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer – developerwjk Jan 16 '14 at 00:29

1 Answers1

-1

Mine default php.ini on maverick

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on NT, not valid in Windows 95).
;mail.log = syslog

A common problem is that a ISP has blocked port 25, for development i have modified the php.ini section mail as below, the smtp port of my mail server changed to port 587 and changed the hostname.

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.example.net
; http://php.net/smtp-port
smtp_port = 587
sendmail_from = user@example.net
auth_username = user@example.net
auth_password = password
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
Joris Ros
  • 389
  • 2
  • 6