I am looking for a way to configure wordpress on my RHEL4 machine to send out email notifications using gnupg (sendmail).
Can anyone point me in the right direction?
WordPress uses it's own function wp_mail() to send out emails. Since it is a 'pluggable' function, you can override it with your own version in a WordPress plugin;
/**
* Plugin Name: GNUPG Mail
* Description: Send mail using GNUPG.
*/
function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
{
// use the PHP GnuPG library here to send mail.
}
Related
I want to send a total of 1650 mails on Christmas eve from a WordPress website.
This is my current code:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=" . get_bloginfo('charset') . "" . "\r\n";
$customers = get_users($args);
$cus_arr = array();
foreach($customers as $customer){
array_push($cus_arr,$customer->data->user_email);
}
wp_mail($cus_arr, $subject, $message, $headers);
/*another way*/
...
foreach($customers as $customer){
wp_mail($customer->data->user_email, $subject, $message, $headers);
}
Question 1 : Is the above way a good choice for sending a mail to this amount of customers? May there be any problem? Is there any better way of doing it?
Also I dont want customers to see each others mail. This is my current code:
wp_mail(array("BCC: xyz#xyz.com","BCC: abc#abc.com"), $subject, $message, $headers);
But it does not work. Without BCC: the mails are actually sent.
Question 2. How can I prevent users from seeing other mail ids?
Question 1: It's good practice to use a rate limit(throttling), e.g. max 100 mails/10 minutes. You can do this by storing the recipients in a database, and use a cronjob to send mail every 10 minutes. Another option is to use a 3rd party mail service, such as Mandrill or Sendgrid, they'll handle throttling for you.
Question 2: Your current code calls wp_mail for each recipient, so they'll never see other mail addresses (no need for BCC headers). However if you decide to use wp_mail to send to multiple recipients in 1 call, you need to use bcc headers, e.g.:
wp_mail('', $subject, $message, array("BCC: xyz#xyz.com","BCC: abc#abc.com"));
Hey there I think your code is a bad idea because of the following reasons:
The script may exceed the max execution time or the memory limit of the server
it may work, but wp_mail is just not a good solution for sending this huge amount of emails
What I would recommend is to use a library for sending bulk e-mails. There are existing WordPress Plugins for this purpose however you can easily do it yourself - here is my solution with the classic, well tested PHPMailerLibrary (https://github.com/PHPMailer/PHPMailer):
In your functions.php:
require("libs/phpmailer/PHPMailerAutoload.php");
/**
#param $from: The senders E-Mail
#param $from_name: The senders Name
#param $subject: The E-Mail subject
#param $mesesage: The E-Mail content HTML
#param $to: An array of receivers
*/
function my_custom_send_mass_mail($from,$from_name,$subject,$message,$to) {
// first use PHPMailer to send all the emails
$email = new PHPMailer();
$email->isSMTP();
$email->CharSet = 'utf-8';
$email->From = $from;
$email->FromName = $from_name;
$email->Subject = $subject;
$email->Body = $message;
$email->IsHTML();
if(is_array($to)) {
foreach($to as $t) {
$email->addBCC($t);
}
}
$ac = time();
update_option('mailsent-'.$ac,$email);
$success = $email->send();
if($success) {
update_option('mailsent-suc-'.$ac,"yes");
return "Bulk E-Mail successfully sent.";
}
update_option('mailsent-suc-'.$ac,$email->ErrorInfo);
return "Bulk E-Mail Error: Please contact admin.";
}
Just call this function and make sure $to is the array of receiver e-mails.
This is the solution I am using for a customer sending a 10000 E-Mail newsletter weekly and it works great so far.
My Wordpress site registration email gets into the spam folder.
My client uses an old version of Microsoft exchange without SMTP support.
so I can't send the mails true SMPT. And my servers Pp is not Blacklisted.
Domain:
cottex.se
SPF on the Domain:
v=spf1 mx a ip4:178.62.70.32 ?all
I have not setup DKIM(DomainKeys Identified Mail) Because I can't find how to sign the WordPress outgoing mail with a private key.
I really can't understand whats wrong! the SPF should be enough or?
I would like to recommend test your mail on this website
It show you details about problems on the your mail domain.
Send message to specified email and click blue button.
Please use this code its help you:-
Note: You need to use valid email and name here.
add_filter( 'wp_mail_from', 'my_mail_from' );
function my_mail_from( $email ) {
return "enter yout 'from' id";
}
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from_name($old) {
return 'enter your "from name"';
}
wp_mail( $admin_mail, $subject, $message );
I recently installed buddypress in my wordpress.
When a person registers on my website using registration form
a message appears saying that an activation link has been sent to the email address you provided, but user receives no email.
Please tell me to solve this.
is there any problem in wp_mail or do I need to config
something in my hosting file manager?
First , test the wp_mail function with the following code by creating wp-test.php in root folder.
include 'wp-load.php';
$to = 'example#example.com';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($to, $subject, $body, $headers);
After that if it's still not working , you need to install and configure Easy WP SMTP and setup the SMTP settings from your host.
I am not getting any emails (to the admins) from my Wordpress app on open shift. I installed it using the wordpress example.
I have a contact page form that was working in my other hosting provider.
any ideas?
I had an issue before where emails weren't sending and I added this to my functions.php file:
/**
* change WordPress default FROM email address
**/
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
$email = get_option( 'admin_email' );
return $email;
}
function new_mail_from_name($old) {
$site_name = get_option( 'blogname');
return $site_name;
}
I would erase all of that. I am a very good user in this situation.
#1 every time you change the server, you have to redo the mailer settings.
#2 only and I do mean only use wp-mailer plugin.
#3 set your settings correctly and follow the instructions if you are using wordfence.
#4 for woo, you have to style the mailer in ftp.
I'm in need of help for a custom form in which emails are not being sent.
Context: Within Drupal, I have installed the following modules: PHPMailer, SMTP Authentication Support, Mail System and Mime Mail.
Configuring the above modules you have the option to test your configurations and when preforming such tests emails are being sent properly. However, when writing a module for a form, emails are not being sent.
I don't get any type of erros nor message. I just don't get the email.
Here is the snipped of code that I'm using:
function application_form_submit($form, &$form_state) {
$subject = "testing web form";
$body = array();
$body[] = "Mail body";
$send = FALSE;
$mail_message = drupal_mail('application', 'apply-jobs', 'email#gmail.com', language_default(), $params = array(), $from = 'user#test.com', $send);
$mail_message['subject'] = $subject;
$mail_message['body'] = $body;
$mail_system = drupal_mail_system('application', 'apply-jobs');
$mail_message = $mail_system->format($mail_message);
$mail_message['result'] = $mail_system->mail($mail_message);
}
Suggestions?
You've got an odd way of defining optional parameters. This bit:
$from = 'user#test.com'
will evaluate to... nothing
Try changing your drupal_mail() call like this:
$mail_message = drupal_mail('application', 'apply-jobs', 'email#gmail.com', language_default(), array(), 'user#test.com', $send);
I found the solution to my question. The solution is:
The Mail System module allows one to Configure Mail System settings per module, which means that I had to create new mail system for my customized module an indicate the mail system that I want to use. After I did this, all my email are being sent without any problems.
Hope this helps someone, as there is very little information about this.
Thank you all.