Forum Moderators: coopster

Message Too Old, No Replies

connecting and sending mail to an smtp server.

how do i send a mail to an smtp server using a username and password to con

         

cyberjunky

5:27 pm on May 26, 2006 (gmt 0)

10+ Year Member



hi,

basically, the problem is, i need to send an email to smtp.example.co.uk and to access the smtp i need to enter and username and passowrd, ive fiddles with the mail() function but i cant figure out how to make it connect to smtp.example.co.uk as my webhost does not have their own smtp server unfortunatly.

all i want to do is connect to the smtp server with the following:
$domain = "smtp.example.co.uk";
$user = "username";
$pass = "password"; //wont disclose real details on forums

then send the email composed of:
$from = $_POST['email'];
$to = "sales@example.com";
$subject = $_POST['sub'];
$message = $_POST['message'];

its a shame as far as im aware phps mail function does not allow you to send to a custom smtp with a username and password, as far as im aware this is not possible, any ideas?

your help on the matter is most appreciated.

[edited by: coopster at 3:49 pm (utc) on May 30, 2006]
[edit reason] generalized url [/edit]

eelixduppy

5:50 pm on May 26, 2006 (gmt 0)



If you have access to your php.ini file, you can change the SMTP and the smtp_port there. They are defaultly set to 'localhost' and '25' respectively. Or you can use ini_set [us2.php.net] (ie ini_set("SMTP","http://smtp.example.co.uk"))

[edited by: coopster at 3:50 pm (utc) on May 30, 2006]
[edit reason] generalized url [/edit]

cyberjunky

11:08 pm on May 26, 2006 (gmt 0)

10+ Year Member



but how do i set the username and password to the smtp?

coopster

4:11 pm on May 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The configuration directives mentioned only pertain to Windows platforms. PHP's mail [php.net] function uses the sendmail binary on your system. If you want to connect to an SMTP server you need to open a socket. You can do this yourself using fsockopen() [php.net] or you can use the PEAR mail package [pear.php.net]. There are other mailer packages available as well.