Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( $message && !wp_mail($user_email, $title, $message) )
- <?php
- /**
- * Plugin Name: Stackexchange Testplugin
- * Plugin URI: http://yoda.neun12.de
- * Description: Send me a test email
- * Version: 0.1
- * Author: Ralf Albert
- * Author URI: http://yoda.neun12.de
- * Text Domain:
- * Domain Path:
- * Network:
- * License: GPLv3
- */
- namespace WordPressStackexchange;
- add_action( 'init', __NAMESPACE__ . 'plugin_init' );
- function plugin_init(){
- $to = 'your-email-adress@some-domain.tld';
- $subject = 'Testemail';
- $message = 'FooBarBaz Testmail is working';
- wp_mail( $to, $subject, $message );
- }
- define( 'WP_DEBUG', true );
- define( 'WP_DEBUG_LOG', true );
- define( 'WP_DEBUG_DISPLAY', true );
- @ini_set( 'display_errors',1 );
- if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
- $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header);
- } else {
- $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header, $params);
- }
- // Send!
- try {
- return $phpmailer->Send();
- } catch ( phpmailerException $e ) {
- //------------- This next line is the one to add -------------------
- if (WP_DEBUG) echo '<pre>' . esc_html(print_r($e, TRUE)) . '</pre>';
- return false;
- }
- <?php
- function sendgridmail($to, $subject, $message, $headers)
- {
- $url = 'https://api.sendgrid.com/';
- //$user = 'yourUsername';
- //$pass = 'yourPassword';
- $params = array(
- 'api_user' => $user,
- 'api_key' => $pass,
- 'to' => $to,
- 'subject' => $subject,
- 'html' => '',
- 'text' => $message,
- 'from' => 'abc@hotmail.com',
- );
- $request = $url.'api/mail.send.json';
- // Generate curl request
- $session = curl_init($request);
- // Tell curl to use HTTP POST
- curl_setopt ($session, CURLOPT_POST, true);
- // Tell curl that this is the body of the POST
- curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
- // Tell curl not to return headers, but do return the response
- curl_setopt($session, CURLOPT_HEADER, false);
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
- // obtain response
- $response = curl_exec($session);
- curl_close($session);
- // print everything out
- //print_r($response);
- }
- //only for testing:
- /*$to = 'abc@yahoo.com';
- $subject = 'Testemail';
- $message = 'It works!!';
- echo 'To is: ' + $to;
- #wp_mail( $to, $subject, $message, array() );
- sendgridmail($to, $subject, $message, $headers);
- print_r('Just sent!');*/
- if (!function_exists('wp_mail')) {
- function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
- {
- // use the PHP GnuPG library here to send mail.
- sendgridmail($to, $subject, $message, $headers);
- }
- }
- function plugin_init()
- {
- /* $to = 'xyz@yahoo.com';
- $subject = 'Testemail';
- $message = 'It works Live!';
- //echo 'To is: ' + $to;
- wp_mail( $to, $subject, $message, array() );
- //print_r('Just sent!');*/
- }
- @mail("example@exmaple.com",$title,$body,$headers,"-fexample@exmaple.com");
- <?php
- $to = "example@gmail.com";
- $subject = "Test Email Function";
- $txt = "Hello world!";
- $headers = "From: webmaster@example.com" . "rn" .
- "CC: xyz@example.com";
- mail($to,$subject,$txt,$headers);
- ?>
- sudo apt-get install sendmail
Add Comment
Please, Sign In to add comment