I want to send mail to my gmail account from my website but it s giving some error please check it http://www.visitallahabad.com/contact.php My code is <?php require_once "Mail.php"; $from = "Sandra Sender <contact@visitallahabad.com>"; $to = "Ramona Recipient <o.jkesharwani@gmail.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "mail.visitallahabad.com"; $username = "contact@visitallahabad.com"; $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>"); } ?> PHP:
The request is not able to reach to smtp. Check whether your smtp server is listening to port 25 only or on some other port? Alternately, you can try phpmailer keeping debug mode on for detailed error analysis. PHPMailer
You can use fsockopen() php function (see official manual at php.net/fsockopen) to check if there's some answer at 25 port. And you can specify the timeout, for example, 1 second (by default it's 30 sec).
Exactly, why are you complicating things. Just use the simple mail() function in PHP to send Contact-Us feedback to your email account. If you would like a ready made script, let me know -- i will send it to you.
Is it me or PEAR are not available on that many hosting? Just use standard PHP mail() though, that should be enough for your everyday's needs.
mail() is working fine with the email id related to my own domain i.e but when i am using ID like or yahoo.com its not working. My requirement is to recieve mails to my gmail ID.
Gmail needs ssl and port 465 I just update my script today and found out that to use gmail you'll need to set the followings: use this as host (add the "ssl://"): "ssl://smtp.gmail.com" And use this for Mail::factory $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'port' => '465', 'username' => $username, 'password' => $password)); PHP: Hope this helps
Now a days mail( ) is not working in many servers.. bcz they prefers through smpt... there is some risk in using mail( ) ......
Thanks Chris S. Taylor . If you can please provide me script. My requirement: when i approve the selected members a welcome mail should be send to their email ID. Email Id may be yahoo,gmail, hotmail etc...