11 Replies - 750 Views - Last Post: 28 April 2019 - 10:14 PM Rate Topic: -----

#1 victorkhim89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-April 19

PHP sending email failed

Posted 18 April 2019 - 08:09 AM

please help me check what problem why sending email failed thank you!



(File sendmail.php)
<?php
$to = '[email protected]';
$subject = 'LOCALHOST SUBJECT';
$message = 'send from localhost';
$headers = 'From:[email protected]';
if(mail($to,$subject,$message,$headers))
{
echo "Email sent";
}
else
{
echo "Email sending failed";	

}
?> 




(File sendmail.ini)
; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

:code:
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=465

; 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

smtp_ssl=ssl

; 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

[email protected]
auth_password=123456

; if your smtp server uses pop3 before smtp authentication, modify the 
; following three lines. do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify 
; the "From: " header of the message content

[email protected]

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify 
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

hostname=localhost



(FIle php.ini)
[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 ="[email protected]"

; 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 "

This post has been edited by modi123_1: 18 April 2019 - 08:13 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: PHP sending email failed

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14987
  • View blog
  • Posts: 59,839
  • Joined: 12-June 08

Re: PHP sending email failed

Posted 18 April 2019 - 08:11 AM

Please explain the issue, and copy/paste any errors you may have.
Was This Post Helpful? 0
  • +
  • -

#3 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: PHP sending email failed

Posted 18 April 2019 - 08:37 AM

If you're using sendmail and it's rejecting what you're giving it, I would suggest looking in sendmail's error log.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6753
  • View blog
  • Posts: 31,250
  • Joined: 10-May 07

Re: PHP sending email failed

Posted 18 April 2019 - 10:26 AM

If you are using GMail for SMTP, is the account configured for app passwords?
Was This Post Helpful? 0
  • +
  • -

#5 victorkhim89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-April 19

Re: PHP sending email failed

Posted 19 April 2019 - 12:43 AM

password is correct i use my personal gmail account now i put temporary password only

may be SMTP problem ?

pPlease help me check my code

can send to me a correct PHP sendmail file?
Was This Post Helpful? 0
  • +
  • -

#6 euro-space   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 21-January 19

Re: PHP sending email failed

Posted 19 April 2019 - 04:53 AM

If you're trying to send email using Google's SMTP service, you'd also double check, if your hosting provider has allowed you SMTP connections to the remote servers, due to security reasons this operation has to be allowed on server firewall for particular user.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6753
  • View blog
  • Posts: 31,250
  • Joined: 10-May 07

Re: PHP sending email failed

Posted 19 April 2019 - 07:56 AM

View Postvictorkhim89, on 19 April 2019 - 03:43 AM, said:

password is correct i use my personal gmail account

My comment was not about the password being correct or not, it was in regards to how Google handles application authentication vs human authentication.

...

View Postvictorkhim89, on 19 April 2019 - 03:43 AM, said:

may be SMTP problem ?


View PostArtificialSoldier, on 18 April 2019 - 11:37 AM, said:

If you're using sendmail and it's rejecting what you're giving it, I would suggest looking in sendmail's error log.

I assume this suggestion was skipped. Looking at the logs takes away the guess work.
Was This Post Helpful? 0
  • +
  • -

#8 victorkhim89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-April 19

Re: PHP sending email failed

Posted 23 April 2019 - 08:49 AM

How to looking in sendmail's error log?

How to security reasons this operation has to be allowed on server firewall for particular user?
Was This Post Helpful? 0
  • +
  • -

#9 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: PHP sending email failed

Posted 23 April 2019 - 09:39 AM

It's in your config file.

; 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 those files don't exist, create them, and make sure they are writable.
Was This Post Helpful? 0
  • +
  • -

#10 victorkhim89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-April 19

Re: PHP sending email failed

Posted 28 April 2019 - 05:52 AM

ok thanks i try check
Was This Post Helpful? 0
  • +
  • -

#11 victorkhim89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-April 19

Re: PHP sending email failed

Posted 28 April 2019 - 06:57 AM

How to security reasons this operation has to be allowed on server firewall for particular user?
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6753
  • View blog
  • Posts: 31,250
  • Joined: 10-May 07

Re: PHP sending email failed

Posted 28 April 2019 - 10:14 PM

Firewalls are at the OS level, I've never seen one that operated on a user level.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1