TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,022
  • Total Topics: 21,332
  • Online today: 473
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 324
  • Total: 324

Quick sendmail query

Started by ed_m, July 20, 2009, 09:13:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ed_m2

hi peeps,

i'm trying to use the smf sendmail function in a block to send a validation email for a competition.

however when it gets to that bit of the code it crashes and doesnt render anything below the sendmail command... probably something really obvious but...


               $email = 'ed@email.com';
               $subject = 'test';
               $message = 'email test';
               
               sendmail($email, $subject, $message);


do i need to include something at the top of the block to get this to work ?
or is my syntax just plain wrong ?

cheers,
ed

JPDeni

You're sure that it's this bit of code that's causing the problem and not something before it?

You're not getting any error messages? It seems to me that it should be all right. The only possibility would be if it couldn't find the sendmail function, but you'd be getting an error message telling you that.

I would create a temporary block and just put that code in it -- nothing else. Load the page once, then disable the block (so you don't end up getting dozen's of emails :) ). See if you get one, though. If you do, you'll know your code is right and your error is elsewhere in your code.

ed_m2


ah yes should have thought of isolating the code.... in a php article or in a block it just hangs at that line.

no error no nuffin.

will do some more playing tomorrow :-)

ed_m2

bah.. i don't know.
no error in smf error logs.

have been looking for a known good working example to use.. anyone got one ? ... or can stick the above in a php article and confirm it works for them ??

JPDeni

I tried it out. You need to load in the file with the function.

Add this at the beginning of your code:


require_once('Subs-post.php');

ed_m2

cheers JP ... i came to the same conclusion on my run this evening !

none of the functions that use the sendmail would be used in building the page usually.

ed_m2


Just for completeness here's the basic working syntax:


global $sourcedir;
require_once($sourcedir . '/Subs-Post.php');

                $email = 'ed@email.com';
                $subject = 'test';
                $message = 'email test';
               
                sendmail($email, $subject, $message);

Lesmond

I am curious why you are using a block to send mail, and not the built in news letter function of smf? maybe me but I don't quite understand it  :idiot2:

ed_m2

i'm actually using it in a php article....

and its for a competition entry which:
- renders a form
- checks the content
- sticks the data in a table
- sends an email to the entrant to validate their entry (with a link back to the page)
- validates the entry when the link in the email is followed

i previously had this working as standalone php before i went to smf/tp
the sending mail was a minor annoyance during converting it to an article !

ed_m2

ok.... driving me nuts now... how can i get a new line within the message string ?

(without sending an html email)

This website is proudly hosted on Crocweb Cloud Website Hosting.