Hi,
I am very new to php development. I tried one simple mail program in php
<?php
$to = "ysarunn@gmail.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.";
?>
But i am getting error like "SMTP Server Response:454.5.7.3 Client does not have permission to submit to mail server in C:/Wamp/www/mail/mail.php on line 7"
I am trying in my home laptop only.
Pls help me how to work with this mail functionality.
Need help in Mail Functionality
Moderator: General Moderators
-
rajeevbharti
- Forum Newbie
- Posts: 12
- Joined: Fri Oct 30, 2009 12:43 am
- Location: Delhi
Re: Need help in Mail Functionality
ask the server admin for SMTP user and pass
then send mail using the SMTP method
and then user this code to send the mail
<?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>");
}
?>
then send mail using the SMTP method
and then user this code to send the mail
<?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>");
}
?>
Re: Need help in Mail Functionality
I am trying in my home only. It's not possible to work in home.
If not, Is there any other way to send mail using php programe.
Some frnds are suggesting local mail server. Can anyone help what's that mail server and how to use and can i use in my home laptop.
If not, Is there any other way to send mail using php programe.
Some frnds are suggesting local mail server. Can anyone help what's that mail server and how to use and can i use in my home laptop.