By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

PHP Mail() and versions

P: n/a
I'm using PHP 5 at home w/Apache & MySQL on a test system where I
write through a form to a database and also send an email to people on
a drop down list. Purpose for this is an electronic log at work where
an email goes out to let a person know an entry has been made with a
copy of the text on that email. Works fine on my test system at home
but not at work. I'm trying to remember which version of PHP I'm
using there and I'm thinking it's an early 4.x version (4.1 maybe).

A couple of questions come to mind. Assuming that it is in fact, the
early 4.x version that's responsible (because I'm not sure when the
mail() function came into being (which PHP version), would it be
possible to just copy a later folder version of PHP onto the version
at work? I suppose if I dropped version 5 folder on top of the
existing version 4 and it didn't work, I could just reverse that
process and put my earlier version of 4.x back to get back to where I
was... OR, is using something like phpmailer a better option?

thanks very much for any pointers,

cov
Feb 24 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Feb 24, 5:13 am, cover <coverlandNOSPAM...@yahoo.comwrote:
I'm using PHP 5 at home w/Apache & MySQL on a test system where I
write through a form to a database and also send an email to people on
a drop down list. Purpose for this is an electronic log at work where
an email goes out to let a person know an entry has been made with a
copy of the text on that email. Works fine on my test system at home
but not at work. I'm trying to remember which version of PHP I'm
using there and I'm thinking it's an early 4.x version (4.1 maybe).

A couple of questions come to mind. Assuming that it is in fact, the
early 4.x version that's responsible (because I'm not sure when the
mail() function came into being (which PHP version), would it be
possible to just copy a later folder version of PHP onto the version
at work? I suppose if I dropped version 5 folder on top of the
existing version 4 and it didn't work, I could just reverse that
process and put my earlier version of 4.x back to get back to where I
was... OR, is using something like phpmailer a better option?

thanks very much for any pointers,

cov
Dear Cover,

mail() exists much longer than 4.1. Only thing which changed in 4.3 is
the support for smtp_port. Have a look at the manual:

http://at.php.net/manual/en/ref.mail.php

It's more likely that your operating system is the problem, what are
you using? Is the path to sendmail configured correctly? Do you have
sendmail at all? Etc....

Good luck

Martin
------------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at

Feb 24 '07 #2

P: n/a
On 23 Feb 2007 22:07:55 -0800, "Martin Mandl - m2m tech support"
<ma**********@gmail.comwrote:
>Dear Cover,

mail() exists much longer than 4.1. Only thing which changed in 4.3 is
the support for smtp_port. Have a look at the manual:

http://at.php.net/manual/en/ref.mail.php

It's more likely that your operating system is the problem, what are
you using? Is the path to sendmail configured correctly? Do you have
sendmail at all? Etc....

Good luck

Martin
Thanks Martin, I'm using XP on both machines and to be honest with
you, I'm not real familiar with 'sendmail'. Having read references to
it in various code snips but haven't read anything comprehensive
enough to help me understand what it is and where it is. I.e. I
haven't located a subfolder for 'sendmail' or a sendmail.exe file for
example.

My php.ini look like this:
--------------------------------------------
[mail function]
; For Win32 only.
SMTP = mail.bigfoot.com
smtp_port = 25

; For Win32 only.
;sendmail_from = ad***@maint.com
-------------------------------------------

Page code looks like this:
-----------------------------------------------------------
/* $to = stripslashes($to); */
$to = stripslashes($to)."\r\n";
$subject = stripslashes($subject);
$text = stripslashes($text);
/* mail('$to',$subject, $text); */
mail($to, $subject, $text, "From: ad***@localhosthome.com");
}

mysql_close();
------------------------------------------------------------

Again, this code works well at my home test machine.
Feb 25 '07 #3

P: n/a
cover wrote:
Thanks Martin, I'm using XP on both machines and to be honest with
you, I'm not real familiar with 'sendmail'. Having read references to
it in various code snips but haven't read anything comprehensive
enough to help me understand what it is and where it is. I.e. I
haven't located a subfolder for 'sendmail' or a sendmail.exe file for
example.
sendmail is a mailserver program (MTA), you can find a microsoft version of it
at http://www.indigostar.com/sendmail.htm
My php.ini look like this:
--------------------------------------------
[mail function]
; For Win32 only.
SMTP = mail.bigfoot.com
smtp_port = 25
As microsoft don't have any MTA by default installed, it's required to use an
external mailer, it's quite important to configure this with right smart host
for the client, as nowadays ISPs only allows users to use their SMTP from the
same network.

Using mail.bigfoot.com may work for you at home, but on the remote server
using it as smarthost may not be possible as they aren't on the same network.
--

//Aho
Feb 25 '07 #4

P: n/a

"cover" <co****************@yahoo.comwrote in message
news:bm********************************@4ax.com...
| On 23 Feb 2007 22:07:55 -0800, "Martin Mandl - m2m tech support"
| <ma**********@gmail.comwrote:
|
| >Dear Cover,
| >
| >mail() exists much longer than 4.1. Only thing which changed in 4.3 is
| >the support for smtp_port. Have a look at the manual:
| >
| >http://at.php.net/manual/en/ref.mail.php
| >
| >It's more likely that your operating system is the problem, what are
| >you using? Is the path to sendmail configured correctly? Do you have
| >sendmail at all? Etc....
| >
| >Good luck
| >
| Martin
|
| Thanks Martin, I'm using XP on both machines and to be honest with
| you, I'm not real familiar with 'sendmail'. Having read references to
| it in various code snips but haven't read anything comprehensive
| enough to help me understand what it is and where it is. I.e. I
| haven't located a subfolder for 'sendmail' or a sendmail.exe file for
| example.

here's what i use. it works either on linux or on windows (iis included).
here's how you'd call it:
(note that your drop directory would be c:/inetpub/mailroot/pickup/ ...
also, remove the last argument - it is using sendmail in this case)

email::send(
$site->adminEmail ,
$site->adminEmail ,
'' ,
'' ,
$site->title . ' - Security Alert' ,
'' ,
$html ,
$site->title ,
$site->rootDirectory . 'images/email.logo.jpg' ,
$site->mailDropDirectory ,
'/usr/sbin/sendmail -ti < '
);
and here's the actual class...sends either plain text and/or html:
(you can add attachments to emails with *slight* modification and, notice
that the company logo *is* an attachment...you'd just add another argument,
encode the file(s) to be attached, and add another boundry for each...no
big.)

hth.

<?
class email
{
static function send(
$to ,
$from ,
$cc = '' ,
$bcc = '' ,
$subject ,
$text = '' ,
$html = '' ,
$companyName = '' ,
$logo = null ,
$dropDirectory = '' ,
$exec = '' ,
$execOptions = ''
)
{
$messageHtml = $html;
$html = '
<html>
<style>
body
{
background-color : white;
color : black;
font-family : verdana, tahoma, arial, times new
roman, sans-serif;
font-size : 8pt;
margin : 0px;
text-align : left;
}
</style>
<body>
';
if (isset($logo))
{
$image = file_get_contents($logo);
$image = chunk_split(base64_encode($image));
$html .= '
<img alt="' . $companyName . '" border="0px"
src="cid:logo" style="float:right;">
<br>
<br>
<br>
<br clear="all">
';
}
if ($messageHtml == ''){ $messageHtml = '<html><body>' . $text; }
$html .= $messageHtml . '</body></html>';
if ($text == ''){ $text = $html; }
$boundry = '----=' . md5(uniqid(rand()));
$related = '----=' . md5(uniqid(rand()));
$mail = "MIME-Version: 1.0\r\n";
$mail .= "TO: " . $to . "\r\n";
$mail .= "FROM: " . $from . "\r\n";
$mail .= "CC: " . $cc . "\r\n";
$mail .= "BCC: " . $bcc . "\r\n";
$mail .= "Subject: " . $subject . "\r\n";
$mail .= "Content-Type: multipart/related;
boundary=\"$related\"\r\n\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: multipart/alternative;
boundary=\"$boundry\"\r\n\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$mail .= $text . "\r\n\r\n";
$mail .= "--$boundry\r\n";
$mail .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$mail .= $html . "\r\n\r\n";
$mail .= "--$boundry--\r\n\r\n";
$mail .= "--$related\r\n";
$mail .= "Content-Type: image/jpeg\r\n";
$mail .= "Content-ID: logo\r\n";
$mail .= "Content-Disposition: attachment;
filename=\"logo.jpg\"\r\n";
$mail .= "Content-Transfer-Encoding: base64\r\n\r\n";
$mail .= $image . "\r\n\r\n";
$mail .= "--$related--\r\n\r\n";
$mail .= "-- End --\r\n";
$fileName = $dropDirectory . strtoupper(md5(uniqid(rand()))) . '.eml';
file_put_contents($fileName, $mail);
if (!$exec){ return $mail; }
exec($exec . $fileName . $execOptions);
@unlink($fileName);
return $mail;
}
}
?>
Feb 25 '07 #5

P: n/a

"J.O. Aho" <us**@example.netwrote in message
news:54*************@mid.individual.net...
| cover wrote:
|
| Thanks Martin, I'm using XP on both machines and to be honest with
| you, I'm not real familiar with 'sendmail'. Having read references to
| it in various code snips but haven't read anything comprehensive
| enough to help me understand what it is and where it is. I.e. I
| haven't located a subfolder for 'sendmail' or a sendmail.exe file for
| example.
|
| sendmail is a mailserver program (MTA), you can find a microsoft version
of it
| at http://www.indigostar.com/sendmail.htm
|
|
|
| My php.ini look like this:
| --------------------------------------------
| [mail function]
| ; For Win32 only.
| SMTP = mail.bigfoot.com
| smtp_port = 25
|
| As microsoft don't have any MTA by default installed, it's required to use
an
| external mailer, it's quite important to configure this with right smart
host
| for the client, as nowadays ISPs only allows users to use their SMTP from
the
| same network.

AHO !!! while ms might now have an mta installed by default, the ONLY
version WITHOUT one is XP HOME EDITION. all they have to do is install IIS
(which he already has done) and make sure they select SMTP server as a
component of IIS to install.

a more TRUE statement is that windows does NOT come with a POP3 service.
there are several on the web for free...or, if they already have exchange
installed, neither smtp nor pop3 are an issue. he'll just need to know where
to drop his email on his system.

| Using mail.bigfoot.com may work for you at home, but on the remote server
| using it as smarthost may not be possible as they aren't on the same
network.

again, it's all in how you configure your own server. my prototyping system
is windows xp pro. my production servers are all linux. the only problem
i've ever had with using php and email is when i use php's default mail
function. you've just described one of the problems, however there is no
need to use a remote server to do any emailing.

cheers
Feb 25 '07 #6

P: n/a
Steve wrote:
all they have to do is install IIS
(which he already has done) and make sure they select SMTP server as a
component of IIS to install.
Are you sure? He only mentions whats on his machine, which is apache, which
don't need IIS to be installed to work.

| Using mail.bigfoot.com may work for you at home, but on the remote server
| using it as smarthost may not be possible as they aren't on the same
network.

again, it's all in how you configure your own server. my prototyping system
is windows xp pro. my production servers are all linux. the only problem
i've ever had with using php and email is when i use php's default mail
function. you've just described one of the problems,
Can't say the OP did provide much information, so you need to start somewhere.

however there is no need to use a remote server to do any emailing.
Even if it's possible to send email with telnet (sockets), it may not be the
best solution and if you don't use sockets and you don't have a simple MTA (or
you choose to not use one), a remote MTA is quite sensible to use.
--

//Aho
Feb 25 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.