sending mail through php
Moderator: General Moderators
sending mail through php
Hi, all
can any one suggest me, how to send mail through php.. I m using following code
$to = 'mr.shailendra.shail@gmail.com';
$subject = 'Activation link from IHTIM ';
$message = 'hello, Mr. shail<br> click here';
$headers = 'From: IHTIM@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
but its giving some error, How to configure smtp or pop3 to send it.. Many Many thanks in advance..
can any one suggest me, how to send mail through php.. I m using following code
$to = 'mr.shailendra.shail@gmail.com';
$subject = 'Activation link from IHTIM ';
$message = 'hello, Mr. shail<br> click here';
$headers = 'From: IHTIM@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
but its giving some error, How to configure smtp or pop3 to send it.. Many Many thanks in advance..
Re: sending mail through php
1. what happens if you leave the $headers parameter out? (just for now)
2. what error message do you get?
2. what error message do you get?
Re: sending mail through php
if i leave header parameter outApollo wrote:1. what happens if you leave the $headers parameter out? (just for now)
2. what error message do you get?
"sendmail_from" not set in php.ini or custom "From:" header missing in C:\wamp\www\IHTIM\Trash\sendMailTest.php on line 8
with header parameter
SMTP server response: 550 5.7.1 Unable to relay for mr.shailendra.shail@gmail.com in C:\wamp\www\IHTIM\Trash\sendMailTest.php on line 9
Any way thank for reply.. your any suggestion is welcome..
Re: sending mail through php
Apparently your SMTP server is configured not to allow sending emails from random addresses such as @gmail.com. See if you can change your server's SMTP settings, or use another SMTP server.
If neither of those are possible, you could also use an alternative mail function or class, such as PHPMailer (personally had good experience with that one, using gmail's SMTP server) or Pear or Swift (no personal experience with the latter two, but heard good things about 'em).
If neither of those are possible, you could also use an alternative mail function or class, such as PHPMailer (personally had good experience with that one, using gmail's SMTP server) or Pear or Swift (no personal experience with the latter two, but heard good things about 'em).
Re: sending mail through php
can you give me a small example(code) so that i can get more help.. Many many thanks..Apollo wrote:Apparently your SMTP server is configured not to allow sending emails from random addresses such as @gmail.com. See if you can change your server's SMTP settings, or use another SMTP server.
If neither of those are possible, you could also use an alternative mail function or class, such as PHPMailer (personally had good experience with that one, using gmail's SMTP server) or Pear or Swift (no personal experience with the latter two, but heard good things about 'em).
Re: sending mail through php
how to configure gmail's SMTP. If you have any idea..!!!Apollo wrote:Apparently your SMTP server is configured not to allow sending emails from random addresses such as @gmail.com. See if you can change your server's SMTP settings, or use another SMTP server.
If neither of those are possible, you could also use an alternative mail function or class, such as PHPMailer (personally had good experience with that one, using gmail's SMTP server) or Pear or Swift (no personal experience with the latter two, but heard good things about 'em).
Re: sending mail through php
Using the phpmailer class:shail_csp wrote:can you give me a small example(code) so that i can get more help.. Many many thanks..
Code: Select all
require_once('class.phpmailer.php');
$msg = new PHPMailer();
$msg->IsSMTP();
$msg->Host = "ssl://smtp.gmail.com:465";
$msg->SMTPAuth = true;
$msg->Username = 'gmail_username';
$msg->Password = 'gmail_password';
$msg->From = 'john@example.com';
$msg->FromName = 'John Doe';
$msg->AddAddress('cindy@somewhere.com');
$msg->Subject = 'Testing';
$msg->Body = 'Hello there';
$msg->Sender = $msg->From; // for Return-path
if (!$msg->Send()) die('epic fail...');In your server's PHP configuration is an 'SMTP' value. But you can ignore that if you use the example from above.shail_csp wrote:how to configure gmail's SMTP. If you have any idea..!!!
Re: sending mail through php
Wow it Cool, Thanks.. U r really master of php..Apollo wrote:Using the phpmailer class:shail_csp wrote:can you give me a small example(code) so that i can get more help.. Many many thanks..Code: Select all
require_once('class.phpmailer.php'); $msg = new PHPMailer(); $msg->IsSMTP(); $msg->Host = "ssl://smtp.gmail.com:465"; $msg->SMTPAuth = true; $msg->Username = 'gmail_username'; $msg->Password = 'gmail_password'; $msg->From = 'john@example.com'; $msg->FromName = 'John Doe'; $msg->AddAddress('cindy@somewhere.com'); $msg->Subject = 'Testing'; $msg->Body = 'Hello there'; $msg->Sender = $msg->From; // for Return-path if (!$msg->Send()) die('epic fail...');In your server's PHP configuration is an 'SMTP' value. But you can ignore that if you use the example from above.shail_csp wrote:how to configure gmail's SMTP. If you have any idea..!!!
Is there any way to send sms to any mobile.. through php. Basically I have to send the result message if some one is sending his roll number to my account/number.. How to detect that msg or number and responce to same.. If you have any idea.. !!!!!!
Re: sending mail through php
No idea really, never done anything with SMS. But you better open a new topic for that, as it's pretty unrelated, and put "SMS" in the title to draw people's attention who may be into this sort of thing.shail_csp wrote:Is there any way to send sms to any mobile.. through php.