ankon
ankon

Reputation: 21

I configured my sendmail.ini and php.ini but I can't send an email using mail() function in php

This is my sendmail.ini file:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=****************
[email protected]

After sending an email my debug.log file looks like this:

13/05/27 20:46:36 ** Connecting to smtp.gmail.com:25
13/05/27 20:46:40 ** Connected.
13/05/27 20:46:42 << 220 mx.google.com ESMTP dr6sm30900757pac.11 - gsmtp<EOL>
13/05/27 20:46:42 >> EHLO ANKON-PC<EOL>
13/05/27 20:46:44 << 250-mx.google.com at your service, [202.134.13.131] 

<EOL>250-SIZE   
<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250 ...<EOL>

13/05/27 20:46:44 ** Authenticating as [email protected]
13/05/27 20:46:44 >> STARTTLS<EOL>
13/05/27 20:46:45 << 220 2.0.0 Ready to start TLS<EOL>
13/05/27 20:46:45 >> QUIT<EOL>
13/05/27 20:46:46 <<  5  1Q£q×:Y

ý‰KÿhÓ&ïË‹­¶ð3Àm¼`      ÿ   #  E A > „0‚€0‚é 

13/05/27 20:46:47 <<  F
13/05/27 20:46:47 ** Disconnected.
13/05/27 20:46:47 ** Disconnecting from smtp.gmail.com:25
13/05/27 20:46:47 ** Disconnected.
13/05/27 20:46:47 ** Disconnected.
13/05/27 20:46:47 ** Connection Closed Gracefully.

But actually this things worked for first time but after that it doesn't work. I use xampp in my pc. So what should I do to send an email. Please someone tell me.

Upvotes: 2

Views: 15927

Answers (4)

naik
naik

Reputation: 31

Try: smtp_ssl=none

; SMTPS (SSL) support

; auto = use SSL for port 465, otherwise try to use TLS

; ssl = alway use SSL

; tls = always use TLS

; none = never try to use SSL

Upvotes: 1

user3142546
user3142546

Reputation: 1

  1. Right click on sendmail.exe
  2. property
  3. compatibility
  4. change setting for all user
  5. tick on comptatibility mode.

Upvotes: 0

Spudley
Spudley

Reputation: 168685

You cannot simply specify an external mail server like gmail in this way and expect it to work, even with the correct credentials. You simply won't get this working with the PHP mail() function.

My suggestion is to abandon the mail() function entirely -- it has a lot of shortcomings, of which this is just one.

Instead, download the phpMailer library. This is a PHP class that makes sending mail via PHP much much simpler.

Specifically in your case, it has the ability to send via gMail built-in, meaning that you don't need to mess around with your server config or set up your own mail relay or anything like that; just follow this example to get phpMailer working with your gMail account, and you should be up and running really quickly.

Hope that helps.

Upvotes: 1

Axel Amthor
Axel Amthor

Reputation: 11096

You need to configure your SMTP server / sendmail as full relay host. Since sendmail is quite old and very very very complex to configure, you should consider Exim (as @edwardmp suggests) or postfix.

Actually, your install is missing parts like SSL and going through this would also mean you need to generate server certificates, a cert authority etc etc. and probably other parts are missing as well.

Question is, whether there is a relay host somewhere on the net and reachable and whether you may use that (how is your company sending emails?)

Upvotes: 0

Related Questions