How i can use smtp server to send emails?

apisds

New Member
Messages
20
Reaction score
0
Points
0
You have to set-up an smtp server first (of course). After setting one up, make a user account in the smtp server. Then configure an email client to use the server you created and use the account you created. You can now send emails through the smtp server!

Of course, if you want a detailed answer you must specify your question a little bit further. Like, "How do I setup an smtp server using Ubuntu Linux on a pc box?".
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
Here is how you can send a PHP Simple E-Mail
The simplest way to send an email with PHP is to send a text email.

In the example below I first declare the variables ($to, $subject, $message, $from, $headers), then we use the variables in the mail() function to send an e-mail:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Note: This is the simplest way to send e-mail, but it is not secure.
Regards,
VVBB

---------- Post added at 07:19 PM ---------- Previous post was at 07:14 PM ----------

With SMTP added,
<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
This will be a bit secure as SMTP is to be hit.
Regards,
VVBB
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
@vv.bbcc19: If you're going to copy a script, at least give the details of what is needed. There is a 'require_once "Mail.php";' in that script, how is ravigarg1985 supposed to know what that script is?
 
Top