PHP Mail Function Authentication??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ruddiger52
Forum Newbie
Posts: 2
Joined: Sat Jan 14, 2006 2:17 pm

PHP Mail Function Authentication??

Post 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]
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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.
ruddiger52
Forum Newbie
Posts: 2
Joined: Sat Jan 14, 2006 2:17 pm

Post by ruddiger52 »

Cool thanks for the response
Post Reply