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

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
thetinker
Forum Newbie
Posts: 4
Joined: Wed Aug 05, 2009 5:55 am

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

Post 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" );
?>
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

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

Post by Jade »

Did you check your firewall settings? Are you using some hosting service? Is that why you're using the ini_set functions?
thetinker
Forum Newbie
Posts: 4
Joined: Wed Aug 05, 2009 5:55 am

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

Post 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.
veldthui
Forum Newbie
Posts: 10
Joined: Tue Oct 14, 2008 4:10 pm

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

Post 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.
Post Reply