Giter VIP home page Giter VIP logo

wp_mail's Issues

Conditional Base email sending

Hi,

How can I send and email only if some conditions are satisfied based on the content in template added via template() function of your class.

Thanks!

Wordpress return me 0, what am I doing wrong?

As mentioned in the title, Wordpress return me 0.
I require WP_Ajax and WP_Mail.

This is my code

`

Class Example extends WP_AJAX
{
    protected $action = 'example';

    protected function run(){
		
		if (filter_var($this->get('email'), FILTER_VALIDATE_EMAIL)) {
			
		
		$mymail = get_option( 'simplebooks_news_contact_mail',get_userdata(1)->user_email);
		$email = WP_Mail::init()
		
				->headers([
					"From: ".$this->get('email'),
					"Content-type: text/html; charset=iso-8859-1",
					"MIME-Version: 1.0\n",
					"X-Mailer: PHP " . phpversion()
				])
				->from($this->get('email'))
				->to([$mymail,$this->get('email')])
				->subject(__('New contact from enquiry','simplebooks').': {{name}}')
				->template(get_template_directory() .'/emails/basic.html', [
				'time'    => date('Y-m-d H:i:s'),
				'name'    => $this->get('name').' '.$this->get('surname'),
				'email'   => $this->get('email'),
				'message' => $this->get('message'),
				])
				
			
				->send();
        }
    }
}

`
and this the form


echo'<h2 class="ui header">'.get_option( 'simplebooks_news_contact_text',__('Contact me! Send me a mail!','simplebooks')).'</h2>
			<form class="emailform" action="'.Example::url().'">	
				<div class="ui form text container mail-form">
					<div>
						<textarea id="message" class="mail-text" name="message" placeholder="'.__('Write me a message...','simplebooks').'"></textarea>
						<div class="ui fields  mail-input mail-hidden">
							<div class="ui left icon input field mail-input mail-hidden">							
								<input class="mail-hidden" type="text" name="name" placeholder="'.__('Name','simplebooks').'">	
								<i class="user icon"></i>
							</div>
							<div class="ui field mail-hidden">
								<input class="mail-hidden" type="text" name="surname" placeholder="'.__('Surname','simplebooks').'">	
							</div>
						</div>
						<div class="ui left icon input mail-input mail-hidden">							
							<input  id="email" class="mail-hidden" type="email" name="email" placeholder="'.__('Your email','simplebooks').'">	
							<i class="envelope outline icon"></i>
						</div>
					</div>
					<div>
					<input id="website" class="no_spam" type="text" name="website">
						<button class="ui icon button mail-submit disabled"><i class="envelope outline icon"></i><span class="mail-hidden">'.__('  Send','simplebooks').'</span></button>
					</div>	
				</div>
			</form>
			';	

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.