View previous topic :: View next topic |
Author |
Message |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Thu Jul 01, 2004 5:45 pm Post subject: php.ini mail settings |
|
|
Code: | [mail function]
; For Win32 only.
SMTP = auth.smtp.oneandone.co.uk ; for Win32 only
sendmail_from= xxxxxx ; for Win32 only
; For Win32 only.
;sendmail_from = xxxxxx |
is there anyway to set a password for the mail function in php.ini
thanks
xxxxxx = hidden personal email address _________________ Olly |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Thu Jul 01, 2004 10:16 pm Post subject: |
|
|
I've wondered about that myself. The only way I have seen people do it is send the password in the PHP file itself as a variable (and not set it in the php.ini file).
Here's an example:
Code: | <? php
//mail($catre, $subject, $message, $headers); //old fashion mail, using sendmail, useful on linux
sock_mail(1,$catre,$subject,$message,$headers,$from);//sock version, usable on Win32
//this is the sock mail function
function sock_mail($auth,$to, $subj, $body, $head, $from){
$lb="\r\n"; //linebreak
$body_lb="\r\n"; //body linebreak
$loc_host = "localhost"; //localhost
$smtp_acc = "your_mail_account"; //account
$smtp_pass="your_mail_password"; //password
$smtp_host="your_mail_server"; //server SMTP
$hdr = explode($lb,$head); //header
if($body) {$bdy = preg_replace("/^\./","..",explode($body_lb,$body));}
// build the array for the SMTP dialog. Line content is array(command, success code, additonal error message)
if($auth == 1){// SMTP authentication methode AUTH LOGIN, use extended HELO "EHLO"
$smtp = array(
// call the server and tell the name of your local host
array("EHLO ".$loc_host.$lb,"220,250","HELO error: "),
// request to auth
array("AUTH LOGIN".$lb,"334","AUTH error:"),
// username
array(base64_encode($smtp_acc).$lb,"334","AUTHENTIFICATION error : "),
// password
array(base64_encode($smtp_pass).$lb,"235","AUTHENTIFICATION error : "));
}
else {// no authentication, use standard HELO
$smtp = array(
// call the server and tell the name of your local host
array("HELO ".$loc_host.$lb,"220,250","HELO error: "));
}
// envelop
$smtp[] = array("MAIL FROM: <".$from.">".$lb,"250","MAIL FROM error: ");
$smtp[] = array("RCPT TO: <".$to.">".$lb,"250","RCPT TO error: ");
// begin data
$smtp[] = array("DATA".$lb,"354","DATA error: ");
// header
$smtp[] = array("Subject: ".$subj.$lb,"","");
$smtp[] = array("To:".$to.$lb,"","");
foreach($hdr as $h) {$smtp[] = array($h.$lb,"","");}
// end header, begin the body
$smtp[] = array($lb,"","");
if($bdy) {foreach($bdy as $b) {$smtp[] = array($b.$body_lb,"","");}}
// end of message
$smtp[] = array(".".$lb,"250","DATA(end)error: ");
$smtp[] = array("QUIT".$lb,"221","QUIT error: ");
// open socket
$fp = @fsockopen($smtp_host, 25);
if (!$fp) echo "<b>Error:</b> Cannot conect to ".$smtp_host."<br>";
$banner = @fgets($fp, 1024);
// perform the SMTP dialog with all lines of the list
foreach($smtp as $req){
$r = $req[0];
// send request
@fputs($fp, $req[0]);
// get available server messages and stop on errors
if($req[1]){
while($result = @fgets($fp, 1024)){if(substr($result,3,1) == " ") { break; }};
if (!strstr($req[1],substr($result,0,3))) echo"$req[2].$result<br>";
}
}
$result = @fgets($fp, 1024);
// close socket
@fclose($fp);
return 1;
}
?> |
_________________ Bienvenidos! |
|
Back to top |
 |
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Fri Jul 02, 2004 10:13 pm Post subject: |
|
|
thanks,
I've been trying to modify this part of my script to send email successfully, but I have failed miserably.
Code: | //E-mail error to your e-mail address
$smtp_pass = "xxxx";
$datetime = date("l dS of F Y H:i:s");
$message = "<i>The following error has been received on "."$datetime\n</i><br>\n<br>\n";
$message .= "<b><i>$errorname</i></b><br>\n";
$message .= "<i>Requested URL:</i> " . $requested_url . "\n<br><i>Referring URL:</i> " . $referring_url;
$to = "$email";
$subject = "Web Site Error";
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
mail($smtp_pass,$to,$subject,$message,$headers);
//End of E-mail sender |
if it's relevant it's part of a 138 line custom error page script i'm trying to write, so the variable names must stay the same, thanks again. _________________ Olly |
|
Back to top |
|
 |
WolfRamiO -
Joined: 30 May 2004 Posts: 121 Location: Viña del Mar, Chile
|
Posted: Mon Jul 05, 2004 10:38 am Post subject: |
|
|
Mount Argosoft mail server and Be happie |
|
Back to top |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Mon Jul 05, 2004 11:49 am Post subject: |
|
|
I can’t run a smtp server, it’s ageist the tos of my ISP. You allowed to run a http, and a mysql server.
If they find I’m running an smtp server, they can charge me up to £150, and terminate my broadband access. Then charge me another £50 to re-enable it. That’s a risk I can’t take _________________ Olly |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|