Jump to content

Simple WireMail implementation on localhost..?


hellomoto
 Share

Recommended Posts

I'm trying to send an email notification for each inquiry submitted. Currently they're just saved as pages. I want to email notify too.

So I have (mail part is at the bottom):

// check if the form was submitted
if($input->post->submit) {
	// determine if any fields were ommitted or didn't validate
	foreach($required_fields as $key => $value) {
		 if( trim($value) == '' ) {
			 $error_message = "<p class='error'>Please check that you have completed all the required fields.</p>";
			 $error = true;
		 }
	}
	// if no errors, create a new page
	if(!$error) {
		$p = new Page(); // create new page object
		$p->template = 'vessel_inquiry'; // set template
		$p->parent = wire('pages')->get('/sales/inquiries/'); // set the parent
		$p->name = $input->post->vessel_id . '_' . date('YmdHisu') . '_' . $input->post->user_id;
		$p->title = $input->post->title; // set page title (not neccessary but recommended)
		$p->save(); //create the page
		// populate fields
		$p->message = $input->post->message;
		if($user->isLoggedin()) {
			$p->user = $input->post->user_id;
		} else {
			$p->fullname = $input->post->fullname;
			$p->email = $input->post->email;
		}
		$p->vessel_id = $input->post->vessel_id;
		$p->status = $p->status | Page::statusLocked;
		$p->save(); //save the populated fields

		$success = true;

	 	$mail = new WireMail(); 
	 	// chained method call usage
	 	$mail->to('my@email.com')->from('some@email.com')->subject('Message Subject')->body('Message Body')->send();
	}

This is just to test email sending period. (The to and from emails are actually different ones that I have access to.) I've tried several times to submit inquiries and am not getting anything in spam or anywhere. I'm using XAMPP on OS X.

I know email is complicated and not exactly a ProcessWire matter but do you guys know how I might be able to troubleshoot or resolve this? Surely others here have experience using wireMail() on similar setups... 

Thanks much.

Link to comment
Share on other sites

Try this:

wireMail('my@email.com', 'some@email.com', 'Message Subject', 'Message Body'); 

or

$mail = wireMail();

Also, make sure your php mail function is available and working - likely it isn't on a local dev machine.

So install and set up one of the SMTP options:

http://modules.processwire.com/modules/wire-mail-swift-mailer/

http://modules.processwire.com/modules/wire-mail-smtp/

  • Like 4
Link to comment
Share on other sites

No, you need to give it your email account credentials as you do with your favourite local Emailclient. It uses libs that tests and establishes connection to your account at a smtp provider (like gmail for example) and handles over the messages to it.

It has nothing to do with your settings in the php.ini. Settings in php.ini are related to the php mail() function only!

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...