Jump to content



Photo

Php's Mail Function


  • Please log in to reply
4 replies to this topic

#1 Paul

Paul

    Advanced Member

  • Members
  • PipPipPip
  • 147 posts
  • LocationCumbria, UK

Posted 23 September 2014 - 6:57 AM

Hi all,
I've written the following very simple piece of code.

<?php

echo'
<h1>Your emails</h1>
';

$to = 'demoPHP@localhost.com';

$subject = 'Email testing';

$message = 'test';

mail($to, $subject, $message);

?>

The email doesn't arrive in Thunderbird using Mercury Mail in XAMPP on Windows.

 

The text 'Your emails' appears in the browser so I know the file is being processed by PHP.

I can send an email using Thunderbird from 'demoPHP@localhost.com' to 'demoPHP@localhost.com' and it arrives in the inbox OK, so I know that Mercury is configured OK in that it's sending emails.

I've changed the php.ini file to the following:

 

[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 = postmaster@localhost.com

 

Does anyone have any ideas what I'm doing wrong. I'm actually running a Windows 64bit system. Would that make any difference? I'm referring to the fact that the php.ini file refers to 'Win32'.

 

Thanks

Paul

 


  • 0

#2 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4840 posts
  • LocationState College, PA (USA)

Posted 24 September 2014 - 7:43 PM

Hey Paul. I'd love to help here, but I don't use Windows much and I pretty much never worry about sending email from localhost, so I'm no good on this subject. Hopefully someone else will have some ideas. 


  • 0

#3 Paul

Paul

    Advanced Member

  • Members
  • PipPipPip
  • 147 posts
  • LocationCumbria, UK

Posted 25 September 2014 - 9:15 AM

No problem Larry.

 

However, if you don't use localhost to test your email coding what do you use?

 

My 'plan B' was to upload the code to a stand-alone page on my own live site and test it there. Obviously a bit more of a phaff because there's more chance of me winning a Nobel prize for PHP coding than my code working first time which means going backwards and forwards with FTPs.

 

Cheers

Paul


  • 0

#4 Larry

Larry

    Administrator/Writer

  • Administrators
  • 4840 posts
  • LocationState College, PA (USA)

Posted 26 September 2014 - 8:34 AM

I don't test my email stuff until it's on the live site, normally. Sending out an email from a live server pretty much never has problems. So I'll make sure everything else is working and then make sure the email sending is working as my last rounds of tests on my live server.


  • 0

#5 MichaelSpeds

MichaelSpeds

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 30 September 2017 - 2:19 PM

As mentioned in previous post, the continuous high server load caused another issue that PHP mail function in Wordpress failed to work, not very sure why does this occur maybe some timeout settings of PHP mail?
  • 0