Page 1 of 1

Sending email

PostPosted: 28. November 2009 11:14
by angusmann
Hi all.
Now I know this topic has been done to death but I have searched the forums, searched with google and still can't get it working.

My setup is simple...I just want to be able to send email with attachments (pdf file on the server) to people.

SO - if I understand correctly I just need SMTP. Can anyone point me to a step-by-step setup guide for doing this?

Thanks in advance.
Angus

Probably should say also .. version 1.72 running on Windows 7

Re: Sending email

PostPosted: 29. November 2009 00:01
by Izzy
How are you trying now to send email - what script?

What have you changed in any .ini or .conf file?

Did you Search in forums: XAMPP for Windows and Search for keywords: sendmail

Re: Sending email

PostPosted: 29. November 2009 02:56
by angusmann
I did search for "sendmail" but found nothing that really helped.
A common experience for people seems to be
Q-How do I set up to send email?
A-Easy! Just change A,B, and C like this, and then do this ...
Q-Thanks; I did all that but it still does not work.
A-There is no A. Just silence.

I altered php.ini like this
Code: Select all
[mail function]
; For Win32 only.
SMTP = mail.myisp.com.au
smtp_port = 25

; For Win32 only.
sendmail_from = me@myemail.com

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


And I altered sendmail.ini like this:
Code: Select all
; if your smtp server requires authentication, modify the following two lines

auth_username=myusername
auth_password=mypassword

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

pop3_server=mail.myisp.com.au
pop3_username=myusername
pop3_password=mypassword


And I used this script...
Code: Select all
<?php
$from_name = "Angus";
$from_email = "outgoing@myemail.com";
$headers = "From: $from_name <$from_email>";
$body = "Hi, \nThis is a test mail from $from_name <$from_email>.";
$subject = "Test mail from Justrealized";
$to = "myemail@myisp.com";
if (mail($to, $subject, $body, $headers)) {
  echo "success!";
} else {
  echo "fail…";
}
?>

Note of course I changed the various email addresses to protect privacy.


The problem I have following any of the tutorials I see is that they refer to .ini or .conf files that either don't exist on my setup, or exist at a different location. It's rare to see any instruction on google less than a year or 2 old, and I suspect that different versions of XAMPP have various files at different locations, or in a different format.

Ideally I don't want to be dependent on my ISP's SMTP server, and after (literally) weeks of reading and searching I have found just as many articles saying XAMPP *CAN* be made to work without an external SMTP as I have found saying it *CANT*. All the articles look very convincing, and they all say something like "This is a commonly asked question and there's lots of confusion so I'm posting this to clear it all up." But they never specify the version of XAMPP they refer to. They then go on to refer to files that aren't there, files that are in a different location, or files with set\up options that are different to mine. Often they say "Here's how to send emails on a WIndows machine" and then go on to tell you to change setup options with the heading "; For Unix only."

Sorry to rant but Sheesh. This really is hard. I would prefer silence to all the misinformation that seems to be out there.

Re: Sending email

PostPosted: 29. November 2009 07:23
by Izzy
angusmann wrote:I altered php.ini like this
Code: Select all
[mail function]
; For Win32 only.
SMTP = mail.myisp.com.au
smtp_port = 25

; For Win32 only.
sendmail_from = me@myemail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
You can only use one or the other, SMTP or Sendmail not both, so the php.ini should look like this below because sendmail would be what you need if you are requiring authentication which just about all mail server now require.

You May have to tell your script to use sendmail and possibly it's location.
Code: Select all
[mail function]
; For Win32 only.
;SMTP = mail.myisp.com.au
;smtp_port = 25

; For Win32 only.
; sendmail_from = me@myemail.com

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


angusmann wrote:And I altered sendmail.ini like this:
Code: Select all
; if your smtp server requires authentication, modify the following two lines

auth_username=myusername
auth_password=mypassword

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

pop3_server=mail.myisp.com.au
pop3_username=myusername
pop3_password=mypassword
You are using XAMPP 1.7.2 yet this is not the sendmail.ini file included in this version, it is the fake sendmail instance that was included in versions prior to 1.7.2.

In which case I suggest that you upgraded an earlier version of XAMPP by overwriting the files with the 1.7.2 version files instead of uninstalling the older version, then doing a clean new installation of 1.7.2 as there has been major changes that would require a new installation for 1.7.2.

Only upgrade an earlier version if you see there is an upgrade_version_file on the XAMPP for Windows home page.


This is what the 1.7.2 sendmail.ini looks like
Code: Select all
# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# A freemail service example
account Hotmail
tls on
tls_certcheck off
host smtp.live.com
from [exampleuser]@hotmail.com
auth on
user [exampleuser]@hotmail.com
password [examplepassword]

# Set a default account
account default : Mercury
The entries in this sendmail.ini file are only examples.

A search in forum XAMPP for Windows and a search for keyword msmtp may give a couple of post that went into some detail about this subject only recently.

Re: Sending email

PostPosted: 29. November 2009 08:44
by angusmann
When I originally posted I was running 1.72 as a fresh install on a fresh Windows 7.

Since then I removed 1.72 and "downgraded" to 1.71
Why?
Because with 1.72 I cannot get phpmyadmin access from outside the LAN. I get a confusing error message with an unhelpful suggestion I modify a config file that contains entries I don't understand. After a night of messing around without success I gave up and went back to 1.71

BTW the first 10 results for a search on google for "send email XAMPP" is summarized below..
1-June 15, 2009-Suggests I uncomment "php_smtp.dll" in php.ini. Does not work
2-Dec 26, 2007-Does not work
3-Jan 21, 2006-Forum post with suggestions that don't work
4-May 2, 2008-Suggests modifying php.ini at a location that does not exist.
5-August 7,2005-Confused forum post
6-December 20, 2006-Post on this forum-unhelpful answers
7-October 25,2006-Confused post that deals mainly with drupal
8-April 28,2009-Paid Subscriber site that I can't view
9-Jan 6, 2007-Forum post requesting help but no replies.
10-Jan 25, 2009-Youtube video shows how to setup to send emails only to localhost.

There's not alot of good help out there !

Re: Sending email

PostPosted: 29. November 2009 09:02
by Izzy
That explains the incorrect .ini file and really you should have mentioned that as we here have no way of knowing unless you tell us.

The php.ini file I posted is correct for 1.7.1

The sendmail.ini file may look like this:
Code: Select all
; configuration for fake sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server

smtp_server=mail.myisp.com.au

; smtp port (normally 25)

smtp_port=25

; 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=local

; 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=myusername
auth_password=mypassword

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

; pop3_server=
; pop3_username=
; pop3_password=

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

force_sender=me@myisp.com.au

; 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
That's it, and usually works for most scripts that want to send mail via sendmail couple with the correct php.ini settings which by the way you must restart Apache after editing the php.ini file to have your edits recognised.

Remember that PHP can't in itself send the authentication to your ISP that is why you should use sendmail to do that job.

Also check the error.log and debug.log files in the sendmail folder if or when you send mail you get an error.

The author of Fake Sendmail for Windows, Byron Jones, and his web site link:
http://glob.com.au/sendmail/

This page recommends you contact the author of sendmail for help not covered in the help page by including the debug report after you have your intermittent issues or to report a bug in detail.
http://glob.com.au/sendmail/help/