sending email message using mail()

the mail() function

Moderators: macek, egami, gesf

ass12
New php-forum User
New php-forum User
Posts: 16
Joined: Sat Jan 29, 2005 2:28 pm
Location: england, derby

sending email message using mail()

Postby ass12 » Tue Mar 01, 2005 2:17 pm

hi am trying to send an email using the mail function, does anyone know how to use this function to send an email!

thanks

ass12
New php-forum User
New php-forum User
Posts: 16
Joined: Sat Jan 29, 2005 2:28 pm
Location: england, derby

Postby ass12 » Tue Mar 01, 2005 2:35 pm

im using this code to hopefully send an email

<?php

$to = "ass12@le.ac.uk";
$from = "support@example.com";
$title = "an example";
$body = "e-mailbody
Dear subscriber,

This e-mail confirms your purchase of a 30 day
e-mail support subscription. Please direct all
requests to support@example.com.

Thank you,
The Example.com support staff

e-mailbody";
$success = mail($to,$title,$body);
?>

but im getting this parse error

Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in c:\program files\apache group\apache\htdocs\email.php on line 17

has anyone got any ideas cuz im lost 8-O

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Wed Mar 02, 2005 3:17 am

First of all: this is not a general subject but a php coding => Mail so this topic is now moved there.

The answere to your problem gave PHP itself.. You havens configured your server to send email: in php.ini (you must set smtp, smtp_port, sendmail_from in PHP.ini) from this error message im assuming that you are running on Windows system..

Plus so that you dont even have the headers:

Code: Select all

#setting a header
$headers ="From: me <info@host.com>\r\n";

#Possible to add even the following:
#$headers.="Reply-To: info@host.com\r\n";
#And even more headers...

#now sending
mail($to,$subject,$body,$headers);

ass12
New php-forum User
New php-forum User
Posts: 16
Joined: Sat Jan 29, 2005 2:28 pm
Location: england, derby

Postby ass12 » Wed Mar 02, 2005 8:25 am

i've added the headers in, but firstly i thought the mail function should stil work as long as it has the three parameters to, email message, subject. but anyway i still get the same parse error message im using the code;

<?php

$to = "ass12@le.ac.uk";
//$from = "support@example.com";
$title = "an example";
#setting a header
$header = "From: info@host.com\r\n";
$body = " e-mailbody Dear subscriber,This e-mail confirms your purchase of a 30 day e-mail support subscription. Please direct all requests to support@example.com. Thank you, The Example.com support staff e-mailbody";

#now sending
$success = mail($to,$title,$body,$header);
?>

and my php.ini looks like;

SMTP = localhost ; for Win32 only
smtp_port = 25
sendmail_from= ass12@localhost.com ; for Win32 only

is that how it should be?? and also ive been reading up and i read somewhere that if a firewall is active on the computer then it sometimes blocks the smpt_port = 25 is this true?

any ideas??

cheerz

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Wed Mar 02, 2005 2:06 pm

well... localhost should be entered ONLY if you have an email server installed and running... after you have altered your php.ini you should restart your server..

a firewall might block remote connections to port 25... but try disabeling it and sending again..

darkforce
New php-forum User
New php-forum User
Posts: 5
Joined: Sat Jan 29, 2005 1:08 am

Postby darkforce » Fri Mar 04, 2005 9:16 am

Warning: mail(): SMTP server response: 530 Delivery not allowed to non-local recipient, try authenticating in C:\Program Files\Apache Group\Apache2\htdocs\bookportal\sendmail.php on line 38


can anyone tell me y i got this error msg?

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Fri Mar 04, 2005 9:31 am

because your smtp server doesnt allow you to relay email from non-local senders.. i suggest you configure your email server if you have access to it or use another smtp relay server..


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest