| | |
Cannot send mail through php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
Can you take a look at this:
I keep on getting the else statements.
Here's the code from the form page this email page works with:
Here is my php.ini in the mail portion of it:
[mail function]
; For Win32 only.
SMTP = smtp.va.com
smtp_port = 25
; For Win32 only.
sendmail_from = Admin@va.com
I am using Apache 2.2.8 and Win XP Pro SP2
Can anyone find a solution why I can't send emails to my test address in yahoo.com?
PHP Syntax (Toggle Plain Text)
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $emai=$_REQUEST['txtemai']; $subj=$_REQUEST['txtsubj']; $mess=$_REQUEST['txtmess']; if (@mail($emai,$subj,$mess)) { echo('<p>Mail sent successfully.</p>'); } else { echo('<p>Mail could not be sent.</p>'); } ?> </body> </html>
I keep on getting the else statements.
Here's the code from the form page this email page works with:
PHP Syntax (Toggle Plain Text)
<form method="post" action="Emailed.php"> <input name="txtemai" type="text" id="textfield" size="75" /> </p> <p> Subject: </p> <p> <input name="txtsubj" type="text" id="textfield" size="75" /> </p> <p>Message: <textarea name="txtmess" cols="87" rows="15" id="textarea"></textarea> <input name="button" id="button" type="submit" value="Send" /> </form> </p>
Here is my php.ini in the mail portion of it:
[mail function]
; For Win32 only.
SMTP = smtp.va.com
smtp_port = 25
; For Win32 only.
sendmail_from = Admin@va.com
I am using Apache 2.2.8 and Win XP Pro SP2
Can anyone find a solution why I can't send emails to my test address in yahoo.com?
Last edited by Andrew F.; Jun 17th, 2008 at 8:54 am.
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
I'm very sorry for the confusion but I'm not not yet live so I'm obliged to use localhost but it doesn't work it seems my problem is authentication. How do I solve this?
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
I don't think mail() supports authentication. You can use the PHPMailer package. It's easy to use and well documented. You can find it on SourceForge.
PHP Syntax (Toggle Plain Text)
<?php require_once("PHPMailer/class.phpmailer.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->Host = "localhost"; $mail->From = "****@****.com"; $mail->AddAddress("****@yahoo.com"); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } ?>
Output: Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host.
I still seem to be encountering the problem I was having with vanilla mail.
You may need to add:
PHP Syntax (Toggle Plain Text)
$mail->SMTPAuth = true; $mail->Username = "XXX"; $mail->Password = "YYY";
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
You may need to add:
PHP Syntax (Toggle Plain Text)
$mail->SMTPAuth = true; $mail->Username = "XXX"; $mail->Password = "YYY";
PHP Syntax (Toggle Plain Text)
<?php require_once("PHPMailer/class.phpmailer.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->Host = "ssl://smtp.gmail.com:465"; $mail->SMTPAuth = true; $mail->Username = '****@gmail.com'; $mail->Password = "*****"; $mail->From = "*****s@gmail.com"; $mail->AddAddress("*****@yahoo.com"); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } ?>
Output: It didn't output anything!
I checked my test address at yahoo and no emails were added
PHP Syntax (Toggle Plain Text)
$mail->SMTPSecure = "ssl";
This stuff can all be found by googling for it....
Can you be more specific about the error, perhaps it is something completely different.
Maybe try this one instead: http://www.klenwell.com/is/PhpGmailMailer
Last edited by pritaeas; Jun 19th, 2008 at 9:24 am.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
![]() |
Similar Threads
- smtp mail in php (PHP)
- PHP Developers NEEDED! (Web Development Job Offers)
- Php Form (PHP)
- Send an Email in PHP (PHP)
- PHP mail() (Sendmail) Problem :( (PHP)
- Sending E-mail Within PHP (PHP)
Other Threads in the PHP Forum
- Previous Thread: image in profile.
- Next Thread: image shifts in embedded Windows media player
Views: 4516 | Replies: 20
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





