Page 1 of 1

PHP Mail Function Authentication??

Posted: Sat Jan 14, 2006 2:25 pm
by ruddiger52
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, 

I am relatively new to php. I wrote a little script to send me html form data.  See below. It was working fine until I switched my hoster. I contacted my hoster and they told me that they removed their server as trusted relays, so now all mail sending codes/scripts have to be properly authenticated using a valid "FROM" e-mail address, "USERNAME", and "PASSWORD" of an account currently on their mail netowrk.

I have tried multiple things to no avail. Can anyone please tell me what I need to add to this script to do what they are asking??

Thank you for your time.

Code: Select all

<?

$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$agentemail = $_REQUEST['agentemail'] ;
$body = $_REQUEST['body'] ;

$msg = "\nThis message was sent to you by $name\n\n";
$msg .= "Their E-Mail is $email\n\n";

$msg .= "$body\n\n";

  mail( "$agentemail", "$name would like your help selecting headshots.",
    $msg, "From: $email" );
  header( "Location: headshot.shtml" );


?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Jan 14, 2006 5:50 pm
by Buddha443556
Might try Mail from Pear. Has SMTP backend that allows you to "Sends a mail directly connecting to a smtp server" and more importantly set your username and password and send them using AUTH. Nothing else you can use the Pear code as a guide.

PS: Save Feyd the trouble and fix the your code using [ PHP] [ /PHP] tags.

Posted: Mon Jan 16, 2006 12:11 pm
by ruddiger52
Cool thanks for the response