|
-
Jan 4th, 2006, 08:53 PM
#1
Thread Starter
Addicted Member
Send Email by SMTP
Hello
How can I send an email by SMTP?
I need a PHP sample.
Please help me to get it.
Thank you
Last edited by onh1986; Jan 5th, 2006 at 07:28 PM.
-
Jan 5th, 2006, 11:26 PM
#2
Hyperactive Member
Re: Send Email by SMTP
mail ($_POST['email'], 'subject of email here', 'body of email here', 'From: ur email here');
u have to make sure mail is enabled in the php ini file though
-
Jan 6th, 2006, 01:48 AM
#3
Hyperactive Member
Re: Send Email by SMTP
you should do more then that. As that will get rejected by some servers.
PHP Code:
$to = "[email protected]";
$subject = "You've won 1000$";
$message="This is a message."
#Headers############################################
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: person<[email protected]>' . "\r\n";
mail($to, $subject, $message, $headers);
not the best but it works.
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Jan 6th, 2006, 11:15 AM
#4
Thread Starter
Addicted Member
Re: Send Email by SMTP
But I want to use the SMTP of my website.
-
Jan 6th, 2006, 11:47 AM
#5
<?="Moderator"?>
Re: Send Email by SMTP
You can either change the values in your php.ini file
Code:
[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
smtp_port = 25
sendmail_from= [email protected] ; for Win32 only
or you can set the values dynamicaly if you don't have access to you php.ini file.
PHP Code:
ini_set("SMTP","localhost");
The final method is to use sockets to connect manually to your SMTP server and send it that way, its the hardest is pointless as PHP already has built in support for sending emails, but if you want to use sockets them heres a link:
http://uk.php.net/sockets
-
Jan 6th, 2006, 02:03 PM
#6
Fanatic Member
Re: Send Email by SMTP
The send email that is built into PHP doesn't support SMTP auth, just do a google search for 'SMTP auth PHP'.
-
Jan 6th, 2006, 03:30 PM
#7
<?="Moderator"?>
Re: Send Email by SMTP
Have you looked at:
http://phpmailer.sourceforge.net/
They say that it supports SMTP authentication but i haven't used it so im not sure if it fill definatly fit your needs.
-
Jan 9th, 2006, 02:48 PM
#8
Thread Starter
Addicted Member
Re: Send Email by SMTP
I want a simple php example to send an email by used SMTP.
-
Jan 9th, 2006, 02:54 PM
#9
<?="Moderator"?>
Re: Send Email by SMTP
PHP Code:
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email][email protected][/email] . "\r\n" .
'Reply-To: [email]webmaster@example.com[/email]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set("SMTP","smtp.yoursite.com");
mail($to, $subject, $message, $headers);
?>
Last edited by john tindell; Jan 9th, 2006 at 02:59 PM.
-
Jan 11th, 2006, 07:30 PM
#10
Re: Send Email by SMTP
Irrelivant comments removed. Please don't Chit Chat in this forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|