Assume we have blank WP site and we want to setup SMTP settings programmatically in our plugin or theme. What's the easiest way to do it without changing core files?
While debugging Wordpress password reset functionality in a test environment on a local macbook, Wordpress would get stuck when sending emails. Basically, before sending emails, a check is done in wp-includes/pluggable.php on sender email address, subject, etc, and further debugging showed that Wordpress is failing on line 408 (in version 5.8.2) $phpmailer->setFrom( $from_email, $from_name, false ); Ironically, this built-in check is performed before my custom action would correctly set the parameters: add_action( 'phpmailer_init', 'my_phpmailer_example',5 ); function my_phpmailer_example( $phpmailer ) { …
I've been trying to track down why my s3 bucket files are no longer being attached to automated emails being sent out by WordPress (using the Gravity Forms Entry Automation plugin). I've been able to identify the latest version of PHPMailer being the reason why the attachments no longer get added. From the PHPMailer ticket response: This is due to a bug fix that also closed a major security hole. PHPMailer deliberately avoids being a client for HTTP or other …
I want to set the SMTP settings manually instead of using a plugin. I did this using this resource. However, there is a problem. If the user clicks "Reply", a different e-mail appears. Probably I've described this before with the plugin. However, I cannot remove it. If I make a new definition as below, it creates a new reply e-mail. Therefore, the past is not erased. What I want: If the user clicks to reply to the incoming e-mail, only …
So i've been trying to send email from my functions.php script. When wp_mail function is fired, my entire website crashes. I have enabled all the error display settings in wp-config. I literally copied and pasted the function directly from wordpress.org website, but still my email function causes crash. function send_email(){ $from = "Admin <[email protected]>"; $to = "[email protected]"; $subject = "Lamza Activation"; $message = 'Testing 1 2 3'; $headers[] = "From:" . $from . PHP_EOL; $headers[] = array('Content-Type: text/html; charset=UTF-8'); wp_mail($to, …
I have updated my wordpress to the new 5.7 version, I have a function in my functions.php file to send an email. The thing is, i have used this function before and it all worked well. Now after upgrading, i am unable send email from my custom function send_email() Custom email function in functions.php function send_email(){ $from = "Admin <[email protected]>"; $to = "[email protected]"; $subject = "Lamza Activation"; $activationEmail = ''; $headers = "From:" . $from . PHP_EOL; $headers = array('Content-Type: …
I have a problem with my page. I'm trying to make a "Contact Us" page. It's working perfectly fine design-wise. But when I try to send the form to the same page as origin. It returns 404 error. It only happens when I'm sending the form. I've tried both with GET and POST requests. Nothing seems to work. I've even commented out the PHPMailer part. It's caused entirely by the extra variables. If it helps anything, they're "name", "email" and …
Overall Goal: To have my contact form send me the details to my personal email How do I want to achieve it?: Not using any plugins Issue: When I use my custom PHPMailer function located in the functions.php, the console tells me that there is a POST http://websitename.test/wp-admin/admin-ajax.php 500 (Internal Server Error) ...................... jquery.js?ver=1.12.4-wp:formatted:4206 I am using Laragon for my local server. Whenever I comment out my custom function that uses PHPMailer, Laragon "catches" the email. But whenever I add …
I'm learning about coding plugin. I trying to create a form in plugin page and it can send mail. This is my code, but it doesn't work(I did not receive email and did not show any error). add_action('admin_menu', 'add_contact_us_page'); function add_contact_us_page() { add_menu_page( __( 'Contact Us', 'textdomain' ), __( 'Contact Us','textdomain' ), 'manage_options', 'support_form_page', 'support_form', '' ); } function support_form() { ?> <form action="" method="post" enctype="text/plain"> Name:<br> <input type="text" name="name"><br> E-mail:<br> <input type="text" name="email"><br> Message:<br> <input type="text" name="message" size="50"><br><br> <input …
I have a function in the WordPress functions.php file that searches for a condition in user meta and sends an email to a user based on what it finds. I currently use wp_mail() to send the email, and that works. However, I want to use the included PHPMailer class to do this so that I can send the messages via SMTP. I thought I had a solution here: https://codex.wordpress.org/Plugin_API/Action_Reference/phpmailer_init, however, this seems to only apply to system generated messages, not …
I have a problem where, on a new install of WordPress, I want to add a new user, but the user is not receiving the email with the confirmation link. I've done some research and understand that this can be due to various factors, but before I start hassling my host's technical support, I wanted to know whether there's some obvious reason this would be happening in my situation. Specifically, my WordPress site is installed at subdomain site.example.com, while my …
I'm trying to set up an SMTP gmail server to send emails from my WordPress site. This is what I've got in my wp-config.php: define( 'SMTP_USER', '[email protected]' ); // Username to use for SMTP authentication define( 'SMTP_PASS', 'password' ); // Password to use for SMTP authentication define( 'SMTP_HOST', 'smtp.gmail.com' ); // The hostname of the mail server define( 'SMTP_FROM', '[email protected]' ); // SMTP From email address define( 'SMTP_NAME', 'My Site Name' ); // SMTP From name define( 'SMTP_PORT', '465' ); …
I have an email system that I am making in a WordPress plugin to send the emails with this code: include(PLUGIN_DIR.'config/class_phpmailer.php'); $email = new PHPMailer(); $email->From = get_option('admin_email'); $email->FromName = 'my name'; $email->Subject = $subject; $email->Body = $body; foreach($emails as $mail) { if(is_email($mail)) { $email->addAddress($mail); } } if($name) { $att = PLUGIN_DIR.'uploads/'.date('Ymd').'_'.$name; $email->AddAttachment($att); } // check if email is sent or not if(!$email->Send()) { echo "Message was not sent <br />PHPMailer Error: " . $email->ErrorInfo; } else { echo "Message …
I'm trying to send emails through WordPress using the wp_mail() function and it doesn't seem to work. It's displaying 0 in Chrome 'Network' response with Status Code:200 OK This is my code part: // Contact form Ajax add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form'); function submit_contact_form(){ if(isset($_POST['email'])) { $email = $_POST['email']; $email_to = "[email protected]"; $host = "ssl://smtp.gmail.com:465"; $username = '[email protected]'; $password = 'passpass'; $email_subject = "You have a new email from $email via company.com website"; $message = $_POST['text']; $headers = array ('From' => $email, 'To' …
For testing purposes I've set up a mailtrap (dummy SMTP server) to catch all mail in and out of my local site. To do so, I hooked its configuration in the theme's functions.php like this: function mailtrap($phpmailer) { $phpmailer->isSMTP(); $phpmailer->Host = 'smtp.mailtrap.io'; $phpmailer->SMTPAuth = true; $phpmailer->Port = 2525; $phpmailer->Username = '**************'; $phpmailer->Password = '**************'; } add_action('phpmailer_init', 'mailtrap'); The hook worked like a charm so far, and still does for all front-facing functionalities. Problem is, I now had to expose some …
I've just delved into the WP world and all in all it's going quite well. I have a server at home that I'm using to host the sites. All is working fine except the password emails are not being sent when a user registers. I've hunted quite a lot online but none of the posts that I've found relate specifically to my scenario. Someone hints at 'all I need to do is set the correct ini options' but that's where …
I just want to setup SMTP for a specific instance of wp_mail(). I have tested plugins like "Easy WP SMTP" and also checked how to set up SMTP manually but all these apply to the entire site and then every email from the site is sent through the SMTP account. I don't want to send any other emails like newsletters or comment approval emails through the same SMTP account.
How can I use get_bloginfo('admin_email') in a custom PHP file located in the parent theme root directory? I've built a custom form and a PHP mail script separately, but now I'd like to send the form data to the WP Admin email address with Bcc. $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= 'From: <[email protected]>' . "\r\n"; $headers .= 'Bcc: <'. get_bloginfo('admin_email');'>'. "\r\n"; mail("[email protected]","Form Application",$admin_email_body,$headers); Do I need to include Wordpress functions in the PHP …