Email Sending Feature after registration error - php

Hello guys I am currently working on a registration page on our project Using WORDPRESS where I will send a Confirmation through Email after registration
I am using this Code.. The Code is working right and fine and I also don't see any Error, because if I use it independently without wordpress it is Working. But when I put it inside the wordpress It doesn't send the email at all like in yahoo or gmail? I don't know what is causing the error .
Can you guys give me solution for this?
Sorry for the Bad English.
$peremail = "blablashdjjkas#yahoo.com";
$to = "$peremail";
$subject = "Successfully Registered";
$message = "
Welcome to the Data Portal\n
Thank you very much in trusting Us
Account Detail
Username: $username
Password: $password2";
$header = "From:TITLE Subject \r\n";
$retval = mail ($to,$subject,$message,$header);
But when i use this code outside the wordpress it is working. Don't know what's the error.
BTW the page that I am using is already published online I don't know is there any security issues??
Thank you in advance...

wordpress is using wp_mail function for sending mail.Replace your mail function with wp_mail or you can directly use WP-Mail-SMTP plugin for sending all the mails https://wordpress.org/plugins/wp-mail-smtp/.

Related

Php mailer Email message Blocked

i am using php mailer to send emails for my website the code is working very fine mails are sent properly but as soon as i try to include the verification link of my website the email message gets blocked by gmail service so the issue is i am not able to include the link in my email message please help me out of this .
Message blocked
Your message to saddique116p#gmail.com has been blocked. See technical details below for more information.
$msg = "Thank you for Registering to our website";
$msg.="<html>Welcome<h4> $fname $lname <h4>
Thank You please click this link to verify your Account.
<a href='http://codinginn.000webhostapp.com/verify_email.php?code=$activationcode'>click here</a>
</html>";
The code above is my email body please let know how should i improve this?

Add variables to CodeIgniter email call

I have been trying to create variables to parse into the email class for sending mails in codeigniter. Assuming I want to send a mail to the logged in user, I decided to create a variable
uemail = $_SESSION['email'];But then when I decided to parse it into the email class as $this->email->to($uemail);, does not send the email to the mail. But then when I use $this->email->to('email#email.com'); the mail is sent to the email correctly so I'm thinking I'm experiencing problem with parsing the variable. Doing $this->email->to($_SESSION['email']); too does not work. Please help me out. Thank you .
I just updated my question with detailed codes. I hope this helps. See below;
<?php
$this->Sendmails_model->sendmail();
$uemail = $_SESSION['email'];
$this->email->to($uemail);
$this->email->subject('Email subject here');
$maildata = array(
'firstName' => $_SESSION['first'],
'content' => 'Email content here'
);
$body = $this->load->view('emails/basic',$maildata,TRUE);
$this->email->message($body);
$this->email->send();
?>
For setting session variables you have to use this syntax,
$this->session->userdata('session_variable');
Looking up the link in #Vickel 's comment, $_SESSION['session_variable'] may also be used in CodeIgniter. Hence no problem with the codes.
From your comment, the issue was with the server receiving the email, hence we may consider this question solved.

I can't send mail with Php

I want to send mail with php on my website. I don't know very well php.After I search and I created mail.php files. It's includes this code:
$name = $_POST[“your-name”];
$from = $_POST[“your-email”];
$message = $_POST[“your-message”];
$headers = "From: $mail\r\n"."Content-Type: text/html;Charset=iso-8859-9-r\n ";
mail("admin#ardazaman.com","konu / Subject ", $message ,$headers);
?>
When I send to mail, The output is that:
I won't know what I do. Thank you for helping. Have a good day :).
That's on your email client provider, they don't allow sending html emails.
Best you can do is to contact them to see if there are any workarounds. otherwise you'll have to send a plain email.

500 error after PHP mail()

UPDATE
I was able to get the hosting info from my client and I contacted support, apparently there's an issue with the hosts mail function at the moment and they are working on a resolution. Will wait to see if that's the cause of this problem and will report back.
END UPDATE
I am trying to set up a simple contact form that will send an email. I have the form action set to the below PHP file.
The email gets sent, but the user experience ends with a 500 error instead of sending the user to the confirmation page.
If I comment out the mail() part, then the form redirects the user to the confirmation page successfully, but of course no email gets sent.
The website is hosted on GoDaddy, and I don't have access to the hosting account, though I can try to get it if I need it.
Here's the PHP code:
<?php
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['CITY'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$howdidyouhear = $_POST['hear_about'];
$notifyshow = $_POST['notify_shows'];
$notifyonline = $_POST['notify_online'];
$interest_jewelry = $_POST['Interest_jewelry'];
$interest_prints = $_POST['interest_prints'];
$interest_folkart = $_POST['interest_folkart'];
$interest_indian = $_POST['interest_indian'];
$interest_closeouts = $_POST['interest_closeouts'];
$interest_other = $_POST['interest_other'];
$interest_other_text = $_POST['interest_other_text'];
$spamvalid = $_POST['validate'];
$honeypot = $_POST['website'];
//Spammer Handling
if ($honeypot!=null){echo 'You have been flagged as a spammer, please go away!'; exit;}
if ($spamvalid != '357'){
echo "
<script>
function goBack() {
window.history.back()
}
</script>
You didn't enter the correct number at the bottom of the form. Please try again.<br><button onclick='goBack()'>Go Back</button>";
exit;
}
//START EMAIL
//Body
$mailbody="Name: {$name}\n\nAddress: {$address}\n\nCity: {$city}\n\nState: {$state}\n\nZip: {$zip}\n\nEmail: {$email}\n\nHow did you hear about us?: {$howdidyouhear}\n\nWould you like to be notified when we will be doing a show in your area?: {$notifyshow}\n\nWould you like to receive email notifications of special sales and online events?: {$notifyonline}\n\nWhat brought you to mishuganah.com?: {$interest_jewelry} {$interest_prints} {$interest_folkart} {$interest_indian} {$interest_closeouts} {$interest_other}: {$interest_other_text}\n\n";
//Send Email
mail('matt.rodela#gmail.com','New submission from Mishuganah.com', $mailbody, "From:{$email}\r\n" );
header("Location: http://".$_SERVER["HTTP_HOST"]."/mailing_list/confirmation_page.htm");
?>
I am a relative novice with PHP, so please explain your solutions fully. Thanks!
Use phpMailer instead of php mail() function below you will find reasons not to use built in php mail function
In some cases, mails send via PHP mail() did not receive the recipients although it was send by WB without any error message. The most common reasons for that issue are listed below.
wrong format of mail header or content (e.g. differences in line break between Windows/Unix)
sendmail not installed or configured on your server (php.ini)
the mail provider of the recipeint does not allow mails send by PHP mail(); common spam protection
Errors in the format of header or content can cause that mails are treated as SPAM. In the best case, such mails are transfered to the spam folder of your recipient inbox or send back to the sender. In the worst case, such mails are deleted without any comment. If sendmail is not installed or not configured, no mails can be send at all.
It is common practice by free mail provider such as GMX, to reject mails send via the PHP function mail(). Very often such mails are deleted without any information of the recipient.
So it turns out it was an issue on GoDaddy's end and it has been resolved. The form is working now. Apparently there was nothing wrong with the code.
Thanks for the suggestions folks, I learned some stuff (going to sanatize and filter my inputs now).

having a php page send an email

This question should have a simple, simple answer, but I just can't seem to get it working. Here's the scenario:
I created a php page -> this one: http://adianl.ca/pages/member_application.php. Once the form is completed, it proceeds to http://adianl.ca/pages/member_application_action.php, puts the data into a MySQL db, & thanks the user for their interest. Anyway, the form works perfectly, except for one little thing: whenever someone fills out that form, I want an email to be sent to sbeattie#adianl.ca, informing them that the form was filled out, & the email would include the form components. The problem is, I can NOT get an email to be sent to that address, or any address truth be told. Having a php page send an email should be a simple thing to do, but it's really baffling me.
Can anyone help me with this? This particular problem has been troubling me since yesterday, & if anyone can help me with this...man, thank you soooooo much.
JP
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.adianl.ca"; // SMTP server $mail->From = "webadmin#adianl.ca";
$mail->FromName = "Web Administration [ADIANL]";
$mail->AddAddress("sbeattie#adianl.ca");
$mail->AddCC("justinwparsons#gmail.com"); the #messageBody variable is just a string
If you want to have the email sent using the server's sendmail client, you can use mail.
If you want it to use another mail server, there are extensions to connect to an SMTP server. I use PHPMailer.
If mail doesn't work, it could be that the server is not set up to send email, or it could be that the mail server is rejecting emails sent from php, amongst other reasons.
this code can also be used to email in php so have a look, you can find many more examples of emailing in php look around
?php
$to = "recipient#example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}

Categories