0

I am using XAMPP on a localhost windows VISTA m/c...using gmail as smpt server

I am trying to send an email using simple PHP script

here is the configuration details on sendmail.ini (I have the sendmail.exe and the other 2 dll in that directory)

smtp_server=smtp.gmail.com
; smtp port (normally 25)

smtp_port=465

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

default_domain=localhost

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=xxxxxxx
auth_password=xxxxxx

hostname=localhost

and I have changed the php.ini

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

; For Win32 only.
;sendmail_from = xxxxx

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

and Once I call the script it goes into waiting...for localhost... here is the debug.log...

09/05/02 17:34:41 ** --- MESSAGE BEGIN --- 09/05/02 17:34:41 ** To: [email protected] 09/05/02 17:34:41 ** Subject: Form Submission Results 09/05/02 17:34:41 ** From: My Web Site 09/05/02 17:34:41 ** Reply-To: [email protected] 09/05/02 17:34:41 ** 09/05/02 17:34:41 ** Name: xxx 09/05/02 17:34:41 ** E-Mail: [email protected] 09/05/02 17:34:41 ** Message: hey test message 09/05/02 17:34:41 ** 09/05/02 17:34:41 ** 09/05/02 17:34:41 ** --- MESSAGE END --- 09/05/02 17:34:41 ** Connecting to smtp.gmail.com:465 09/05/02 17:34:41 ** Connected.

I am new to PHP and would like to know if there is a better way to do mail...I am not in for HTML/multipart mails with attachment now... Also i should be able to test in localhost without SMTP server installed . I would like to use GMAIL for now testing. THnks

4 Answers 4

1

I strongly suggest you use a library e.g. PHPMailer. Here is their gmail example.

Another good library (which I haven't used) is SwiftMailer. Here is their gmail example.

Sign up to request clarification or add additional context in comments.

Comments

0

GMAIL needs SSL afaik.

Of free (and probably "good") php mail libraries i know Zend_Mail and Swiftmailer.

Comments

0

You should also check with your ISP. A lot of them block port 25 to prevent spam.

Comments

0

Send Email - GMAIL

1) Stop Server.

2) Change this lines

[XAMPP -> PHP -> php.ini]

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

[XAMPP -> SENDEMAIL ->sendmail.ini]

smtp_port=587 
auth_username= [email protected] 
auth_password= xxxx 
smtp_ssl=auto

3) Run Server

4) Send email test

<?php $to      = '[email protected]'; $subject = 'Test Email
 Email'; $message = 'Hello'; $headers = 'From:
 [email protected]' . "\r\n" .
     'Reply-To: [email protected]' . "\r\n" .
     'X-Mailer: PHP/' . phpversion();

 echo print_r(mail($to, $subject, $message, $headers),true); ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.