Jump to content

Simple WireMail implementation on localhost..?

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.

Share this post

Link to post
Share on other sites

Try this:

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


$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:



  • Like 4

Share this post

Link to post
Share on other sites

Well I have WireMailSmtp enabled and it says my settings appear to work correctly... so now I'm testing my php mail. Do my WireMailSmtp SMTP settings need to match my server/php settings? 

Share this post

Link to post
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!

Share this post

Link to post
Share on other sites

Oh so then the SMTP plugins are separate of PHP mail? Sounds good! But if that's the case, and my settings are supposed to be set up correctly in WireMailSmtp, why won't my email test work?

Share this post

Link to post
Share on other sites

What email provider are you sending your emails from and what email provider are you using as the To: address?

Share this post

Link to post
Share on other sites

Pierre-Luc: so all else the same, just mailto that email address?

cstevensjr I was sending to a gmail email, or just performing the check on save, from another one set up with seemingly correct configuration...

Share this post

Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Peter Knight
      Hi all
      My .htaccess file is correctly redirecting all requests to
      https:// www. That's great until I want to work locally.
      I thought I had seen a blog post by Ryan where there was a new config setting to ignore both of these if working from localhost?
      I can't find it now so wondering if I was imagining 😕
    • By ngrmm
      i'm trying to attach a .ics-file to a mail
      The Page send sends out the email but only download the ics-file. Email has no attachments.
      // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $testEmail = $event->event_mail_test_adress; $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // .ics $filename = $event->name; header('Content-Encoding: UTF-8'); header('Content-type: text/calendar; charset=utf-8'); header("Content-Disposition: attachment; filename={$filename}.ics"); // fetch start date $event_start_ts = $event->getUnformatted("date_start"); // build the .ics data $ical_data = 'BEGIN:VCALENDAR'; $ical_data .= "\r\n"; $ical_data .= 'VERSION:2.0'; $ical_data .= "\r\n"; $ical_data .= 'CALSCALE:GREGORIAN'; $ical_data .= "\r\n"; $ical_data .= 'METHOD:PUBLISH'; $ical_data .= "\r\n"; $ical_data .= 'BEGIN:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'SUMMARY:'.$event->title; $ical_data .= "\r\n"; $ical_data .= 'UID:' . md5(uniqid(mt_rand(), true)) . '@'.$config->httpHost; $ical_data .= "\r\n"; $ical_data .= 'CLASS:PUBLIC'; $ical_data .= "\r\n"; $ical_data .= 'STATUS:CONFIRMED'; $ical_data .= "\r\n"; $ical_data .= 'DTSTART:'.date('Ymd', $event_start_ts).'T'.date("His", $event_start_ts); $ical_data .= "\r\n"; $ical_data .= 'DTSTAMP:'.date('Ymd').'T'.date('His'); $ical_data .= "\r\n"; $ical_data .= 'LOCATION:'.$event->venue; $ical_data .= "\r\n"; $ical_data .= 'URL:'.$event->httpUrl; $ical_data .= "\r\n"; $ical_data .= 'END:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'END:VCALENDAR'; // HTML BODY ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // send email $m = new WireMail(); $m->to($testEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->attachment($ical_data); $m->send();  
    • By ngrmm
      I have a page which sends out an email based on queries in the url
      <?php // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $adminEmail = "events@test.com"; $fromEmail = "noreply@test.com"; $fromName = "test"; $emailSubject = "Test Email"; // HTML BODY $emailBody = ""; // HOW TO ??? … // send mail $m = new WireMail(); $m->to($adminEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); ?> The email body is a bit complex: standard html/css tables and some php (pw variables).
      I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it?
    • By Mithlesh
      Hi there,
      My form is not getting submitted, it is showing:
      Unable to verify successful email delivery of this form submission.
      Attaching for your reference as well: 

      In the Backend, it is showing Connection timed out with smtp.gmail.com
      Pl guide me how to resolve that
  • Create New...