3

This seems like something fairly straightforward and my php script is able to execute. However I am never receiving the mail. Here is the relevant code:

php.ini

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

sendmail_path = "C:\xampplite\sendmail\sendmail.exe -t -i"

sendmail.ini

smtp_server=smtp.gmail.com

smtp_port=587
smtp_ssl=auto
default_domain=mydomain.com
error_logfile=error.log
debug_logfile=debug.log
auth_username=username50@gmail.com
auth_password=passpass

force_sender=myemail@gmail.com
hostname=smtp.gmail.com

Is there anything here I'm missing? My script is sending email to myself. That wouldn't be a problem right?

<?php
$to = "blah@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
AnFi
  • 10,493
  • 3
  • 23
  • 47
hamobi
  • 7,940
  • 4
  • 35
  • 64
  • did you fire up mercury? – t q Jun 04 '12 at 01:38
  • i didnt turn on mercury. i was under the impression its not necessary if you are using an external smtp server the way im using gmail – hamobi Jun 04 '12 at 01:48
  • Have you got the right port? Port for SSL: 465 – bumperbox Jun 04 '12 at 02:03
  • i tried changing it to 465 with no luck – hamobi Jun 04 '12 at 02:09
  • 1
    smtp_server=smtp.gmail.com smtp_port=465 smtp_ssl=auto default_domain=gmail.com auth_username=user50@gmail.com auth_password=pass force_sender=myemail@gmail.com hostname=gmail.com this works – hamobi Jun 04 '12 at 02:28
  • 1
    What does it means "this works"? Have you solved the whole problem (can receive e-mails) or just was able to set port 465 as adviced? In first case, put a formal answer to your own question, so others can see it and make use of it. – trejder Jun 29 '12 at 10:48
  • Use PHPMailer package! – Kiran Reddy Feb 09 '17 at 21:31

1 Answers1

-1

Try this

sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=[email]@gmail.com
auth_password=[email password]
pop3_server=
pop3_username=
pop3_password=
force_sender=[email]@gmail.com
force_recipient=
hostname=smtp.gmail.com

php.ini

[mail function]

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off
Faiz Rashid
  • 82
  • 1
  • 3