PDA

View Full Version : page success but no email sent



suedree
06-01-2007, 08:59 AM
Hai... I'm new in this forum.. I need help in php email. I've got sick searching around the net about this but yet I can't find any solution. So if there anybody out there would help me, I will really appreciate.

1st example

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port=25

; For Win32 only.
sendmail_from = me@localhost.com

php file :
<?php
$to = 'serene@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@localhost.com' . "\r\n" .
'Reply-To: webmaster@localhost.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message,$header);
?>

when I use this one, no error appear, but the email itself does not sent.

2nd example

[mail function]
; For Win32 only.
SMTP = mail.example.com
smtp_port=25

; For Win32 only.
sendmail_from = me@example.com

php file
<?php
$to = 'serene@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();


mail($to, $subject, $message,$header);
?>

an error appear
Warning: Server Error in c:\apache\htdocs\e-score\test_email.php on line 13

and line 13 : mail($to, $subject, $message,$header);

anybody have any idea on how to fix this one????

mbrodin
06-01-2007, 10:11 AM
Hai... I'm new in this forum.. I need help in php email. I've got sick searching around the net about this but yet I can't find any solution. So if there anybody out there would help me, I will really appreciate.

....

when I use this one, no error appear, but the email itself does not sent.

....

an error appear
Warning: Server Error in c:\apache\htdocs\e-score\test_email.php on line 13

and line 13 : mail($to, $subject, $message,$header);

anybody have any idea on how to fix this one????

Hi, Suedree!

You have named "$headers" as "$header" in both cases when you send the mail:

Change to this instead, then you can try again;

<?php

$to = "serene@gmail.com";
$subject = 'the subject';
$message = 'hello';

$headers[] = "From: webmaster@localhost.com";
$headers[] = "Reply-To: webmaster@localhost.com";
$headers[] = "X-Mailer: PHP/" . phpversion();

mail($to, $subject, $message, implode("\r\n", $headers) );
?>

Is this the right soloution?

Best regards,
mbrodin

suedree
06-06-2007, 02:18 AM
Thank mbrodin,
I already figured the error but it seems like I cannot send email from localhost. Is it because I'm doing it in my laptop?? and when I try to setup the php.ini

[mail function]
; For Win32 only.
SMTP = mail.global.com
smtp_port=25

; For Win32 only.
sendmail_from =admin@global.com

<?php

$to = "advin@global.com";
$subject = 'the subject';
$message = 'hello';

$headers= "From: admin@global.com";

mail($to, $subject, $message,$header);
?>

it works but I cannot send email other than global.com such as yahoo or gmail. I still didn't figure it out....

thetestingsite
06-06-2007, 02:23 AM
Yahoo and Gmail mail servers require that you log in to their servers before sending mail through them. Probably, global.com is a mail realyer (subject to spamming and DNS blacklisting) and this is why you are able to send through them. If you were to use your laptop to send emails (if you were running a XAMPP, WAMP, LAMP server), you would need a mail server (or sendmail executable) as well. If you are on a Windows system, I recommend using hMailServer (http://www.hmailserver.com).

Hope this helps.

suedree
06-06-2007, 02:32 AM
Hi thetestingsite,
Thank for the advice... but what you mean by log in to yahoo or gmail servers before sending mail through them?? Is it because they block outside email form coming in??? Let say the global.com is my company's mail server, and I have to set the php.ini like this if not the email cannot be send or an error occurred:

[mail function]
; For Win32 only.
SMTP = mail.global.com
smtp_port=25

; For Win32 only.
sendmail_from = admin@global.com


for gmail and yahoo, do I need to setup the php.ini like this??


[mail function]
; For Win32 only.
SMTP = mail.yahoo.com
smtp_port=25

; For Win32 only.
sendmail_from = admin@yahoo.com


As you say, I'm using windows system so I take ur advice to use hMailserver and I already install it in my laptop, but it seem like this software just to register or add new email to the specific domain but I can't understand how this software work with my php configuration. Can u advice me on how to make it work with my php???