Jump to content

[SOLVED] How to include Email with HTML content


ngrmm
 Share

Recommended Posts

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?
 

Edited by ngrmm
solved
Link to comment
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
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CachePuzzles
      Hi there,
      I'm probably missing something simple, but I'm just setting up my first site so I guess that's bound to happen.
      I've installed the LoginRegistration module and at first I was thinking that the confirmation emails weren't being sent. However I now see that new user confirmation emails are taking 20+ minutes to arrive. Is there a way to speed this up?
      Also the email is coming from processwire@mydomain - I couldn't found a place to change this.
      Any advice or help would be great!
      Brian
    • By fruid
      What's wrong with my code? It just won't send emails. It worked before when not using wiremailSMTP but now it stops. This is used in a contact form.
      It has to be the code because when I run a test in the module, it works fine and the email reaches me.
      Even the Promailer-Newsletters using WireMail SMTP work fine now.
      Even when I put some debug code on the template to be send to me via email with every email, that email reaches me. 
      But somehow the email in question, send with contact form does not.
      BTW if-condition works fine cause redirection works as well.
      Here's my code:
      if (isset($_POST['sendform']) && $captcha->verifyResponse() === true) :     $givenname = $input->post->text('givenname');      $familyname = $input->post->text('familyname');      $fullname = $givenname.' '.$familyname;     $fullname = ucwords($fullname);     $email = $input->post->email('emailaddress');      $subject = $input->post->text('subject');      $message = $input->post->text('message');      $m = wireMail();     $m->to('myemail@mydomain.com', 'my Name');     $m->from($email, $fullname);     $m->subject($subject);     $m->body($message);     $m->send();     $session->redirect($pages->get("/kontakt/danke/")->url); endif; I recently installed a SSL certificate on the webserver, but that should be irrelevant, right?
      Further settings:
      port: 587
      Allow Connection without Authentication: no
      SMTP User and SMTP Password provided
      Use Start-TLS: no
      TLS Crypto method: 1.2
      Use SSL: no
      Allow self signed certificated: no
      Thanks for help!
       
    • 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 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
    • By abdulqayyum
      hello processwire community,
      i am using LoginRegister module for front-end user registration. i am facing an issue verification email not receiving while WireMailSmtp is working perfectly and user receives message
      "Thank you, a confirmation code has been emailed to you. When you receive the email, click the link it contains, or paste the confirmation code below."
      received this message in front-end but does not receive any email relevant it.
      please help me in this case how i can solve it.
      Please check screen shots for SMTP test and message which receives user.
      Thanks AbdulQayyum,

      First screenshot SMTP test message, second when user receives message after clicking register button.
×
×
  • Create New...