-3

I have installed WAMP on windows 8 and am trying to send emails using sendmail. The code returns "email sent", however, the testemail account does not receive any emails in its inbox or spam folder.

This is my sendmail.ini file.(I have tried 25,587,465 for the smtp_port and ssl,blank,none,tls for the smtp_ssl)

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=myaccount@gmail.com
auth_password=mypassword
hostname=localhost

This is the [mail function] of the php.ini file.

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

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

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

And this is my php file for sending emails

<?php
$to = 'testemailaccount@live.com';
$subject='testing';
$message = 'This is a test';

$headers  = 'From: myaccount@gmail.com' . "\r\n" .
        'Reply-To: myaccount@gmail.com' . "\r\n" .
        'MIME-Version: 1.0' . "\r\n" .
        'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

if(mail($to,$subject,$message,$headers))
{
    echo "email sent";
}
else 
{
echo "Invalid Email";
}

?>

This is what I am getting in my debug log file

14/11/12 12:25:11 ** --- MESSAGE BEGIN ---
14/11/12 12:25:11 ** To: testemailaccount@live.com
14/11/12 12:25:11 ** Subject: testing
14/11/12 12:25:11 ** X-PHP-Originating-Script: 0:email.php
14/11/12 12:25:11 ** From: myaccount@gmail.com
14/11/12 12:25:11 ** Reply-To: myaccount@gmail.com
14/11/12 12:25:11 ** MIME-Version: 1.0
14/11/12 12:25:11 ** Content-type: text/html; charset=iso-8859-1
14/11/12 12:25:11 ** X-Mailer: PHP/5.3.13
14/11/12 12:25:11 ** 
14/11/12 12:25:11 ** This is a test
14/11/12 12:25:11 ** --- MESSAGE END ---
14/11/12 12:25:11 ** Connecting to smtp.gmail.com:25
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Socket Error # 10061<EOL>Connection refused.

I have tried googling for the solution and also set my sendmail.exe to run with administrator privileges. I have also enabled IMAP access on myaccount@gmail.com. Can anyone help me with this?

astral
  • 1
  • 1

1 Answers1

0

Google requires authentication, so username and password. You can see their configuration settings for sendmail here.

Any line in the configuration preceded by a ; semicolon is commented out and will not be processed.

Follow the instructions below to set up the SMTP relay service for Sendmail. These instructions are designed to work with a majority of deployments.

Changing server timeouts should not be necessary. In Sendmail, the server timeout is set in the Timeout.datafinal value. By default, it's set to one hour. If the Timeout.datafinal value has been changed to a lower value, raise the value to one hour.

To configure a smarthost for Sendmail:

Add the following line to the /etc/mail/sendmail.mc file: define(SMART_HOST',smtp-relay.gmail.com')

Stop and restart the sendmail server process.

When you've completed your configuration, send a test message to confirm that your outbound mail is flowing. In addition to the server configuration steps listed above, you may need to perform an additional configuration on your server if either of the following is true:

You click the Any address option in the Allowed senders setting and you send mail from a domain you do not own, such as yahoo.com. You send mail without a “From” address, such as non-delivery reports or vacation “out of office” notifications. In these cases, you must configure your mail server to either ensure that the server is using SMTP AUTH to authenticate as a registered apps user or to present one of your domain names in the HELO or EHLO command. See the instructions here.

AbsoluteƵERØ
  • 7,816
  • 2
  • 24
  • 35