Page 1 of 1

sending e-mail form to a non-local e-mail address

Posted: Wed Sep 30, 2009 10:59 am
by thetinker
Hi

I am using the mail() function in PHP. I'm trying to send a form by email to a different email address which is out side of my domain but i'm getting this error (see below). can any one help me with this?

also the php code i've used is under the error.


Warning: mail() [function.mail]: SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

Code: Select all

<?php
 
$from = $_REQUEST['email'];
$firstName = $_REQUEST['firstName'];
$surname = $_REQUEST['surname'];
$question = $_REQUEST['question'];
 
$chairs = $_REQUEST['chairs'];
$safety = $_REQUEST['safety'];
$furniture = $_REQUEST['furniture'];
$paper = $_REQUEST['paper'];
$safes = $_REQUEST['safes'];
$shredders = $_REQUEST['shredders'];
$printerLink = $_REQUEST['printerLink'];
$binding = $_REQUEST['binding'];
$machines = $_REQUEST['machines'];
$stationary = $_REQUEST['stationary'];
 
ini_set ("SMTP","mail.mydomain.com");
 
ini_set('smtp_port', 25);
ini_set ("Username","bryan@mydomain.com");
ini_set ("Password","Password");
ini_set ("sendmail_from","bryan@mydomain.com");
 
 
$to = "someone@some-else-domain.com";
$subject = "Newsletter";
 
$message = "Newsletter\n\nName: $firstName $surname\nE-mail: $from\nBusiness or Personal?: $question\n\nProducts you are interested in:\n\nchairs: $chairs\nsafety: $safety\nfurniture: $furniture\npaper: $paper\nsafes: $safes\nshredders: $shredders\nprinterLink: $printerLink\nbinding: $binding\nmachines: $machines\nstationary: $stationary";
 
$headers = "From: $name <$from>";
mail($to,$subject,$message,$headers);
header( "Location: newsletter-sent.php" );
?>

Re: sending e-mail form to a non-local e-mail address

Posted: Wed Sep 30, 2009 1:00 pm
by Jade
Did you check your firewall settings? Are you using some hosting service? Is that why you're using the ini_set functions?

Re: sending e-mail form to a non-local e-mail address

Posted: Wed Sep 30, 2009 2:01 pm
by thetinker
I don't think it's my firewall as if i use the code to email another acount in my domain it work fine. it's when i try to email the form to one out side of my domain i'm getting the error.

Re: sending e-mail form to a non-local e-mail address

Posted: Wed Sep 30, 2009 3:01 pm
by veldthui
I think it is a problem with your SMTP server. Obviously it requires authentication for anything but local e-mail. You set that up in the php.ini file.
Have not done it myself but have just had a tutorial on how to send e-mail via php.