Unable to sent an email using codeigniter - php

I have a codeigniter with tank auth configured.I was doing all the test and everything was running properly on my development server.I shiftwd all my codes to the productiom server and no activation email of tank auth is being sent.I used gmail cobfiguration in the email vodeingiter config and email was sent but to some emails its not being sent.Why im i unable to sent email using the default codeigniter settinga in the production server.please help

In the function where you sending you data afte completion of task
$email = 'email on which you want to send mail';
$Subject = "Your subject message";
$smsg = null;
$smsg = 'yor message';
$email_from = 'manishatutorsbureau#gmail.com';
$header = 'From: ' . $email_from . "\r\n" .
'Reply-To: ' . $email_from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// Start code for sending mail
mail($email, $Subject, $smsg, $header);

Related

PHP Confirmation Email after filling out Contact Form

I've created a contact page for a project im working on and im having trouble getting it to send a confirmation email to the user. I have the function defined on my emailer page along with the code that sends the contact form to me
public function sendEmail(){ //this will format and send an email to the smtp server
$to = $this->getSenderEmail();
$subject = $this->getSubject();
$message = $this->getMessage();
$headers = "From: <contact#tristonnearmyer.com >";
$from = $this->getCustomerInfo();
//it will use the php mail()
return mail($to,$subject,$message,$from);
}
public function sendConfEmail(){
$userEmail = $this->getRecipientEmail();
$confSubject = "confirmation";
$confMessage = "thank you";
return mail($userEmail, $confSubject, $confMessage);
}
then the functions are used on the contact page
echo $emailTest->sendEmail(); //send email to SMTP server
echo $emailTest->sendConfEmail(); //send confirmation email
I can't seem to figure out why one is working while the other isn't
Please try this code, you need to call the function sendConfEmail after sendEmail success. Also from here you need to modify the header. But base on user3783243 commend better change to PHPMailer or use swift
public function sendEmail(){ //this will format and send an email to the smtp server
$to = $this->getSenderEmail();
$subject = $this->getSubject();
$message = $this->getMessage();
$from = $this->getCustomerInfo();
$headers = 'From: '. $from . "\r\n" .
'Reply-To: youremailhere#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$sendMail = mail($to,$subject,$message,$headers);
if($sendMail){
// Call the function send confirmation
$this->sendConfEmail();
}else{
echo 'failed sent the email';
}
}
public function sendConfEmail(){
$userEmail = $this->getRecipientEmail();
$confSubject = "confirmation";
$confMessage = "thank you";
$from = $this->getCustomerInfo();
$headers = 'From: '. $from . "\r\n" .
'Reply-To: youremailhere#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
return mail($userEmail, $confSubject, $confMessage,$headers);
}

PHP send mail through postfix

I have Postfix and SquirrelMail configured on my server. And user called noreply. So, I am logging to SquirrelMail and sending email to some address. Everything works fine, i am receiving email from noreply#mydomain.com. But when I try to send email from php using mail(),
mail ('test#2ether.net', 'Postfix Test', 'A test email');
server tries to send it from address www-data#mydomain.com. How do I configure it to send emails from noreply#mydomain.com?
I would use PEARMail it is designed to counter such issues, (PHP's "mail()" method is all but useless in today's email meta - too many bots used it ) however the actual answer is this:
$to = 'test#2ether.net';
$subject = 'Postfix Test';
$message = 'A test email';
$headers = 'From: noreply#mydomain.com' . "\r\n" .
'Reply-To: noreply#mydomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

unable to send e-mail using my function

I am facing e-mail sending problem.
e-mail does not send through my e-mail function.
My code is given below:
ini_set("sendmail_from",$_POST['email']);
$to = 'email#gmail.com';
$subject = $_POST['subject'];
$from = $_POST['email'];
$message = $_POST['message'];
$message = wordwrap($message, 70);
mail($to,$subject,$message,$from);
You have to setup your SMTP mail server and mention those details in php.ini before executing your script. For further info, please check http://www.phpeasystep.com/phptu/23.html
In your code you have to set proper header,
you have used $from for header section of mail.
change its value as
$from= 'From: '.$_POST['email']. "\r\n" .
'Reply-To: '.$_POST['email'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
or you can use below solution.
Use PHPMailer API for sending mail. all are inbuilt there.
download complete code form below link
PHPMailer API
goodluck

PHP: Gmail ignoring any email I send it via mail()

When using the below code I am able to send (and receive) email to my Yahoo account, but when sending to my Gmail account, nothing shows up
(and yes, I have monitored the Spam folder for over 4hrs - nothing!).
public function sendEmail($email_addy, $temp_pass)
{
$website_name = $this->website_name;
$message = <<<MESSAGE
Greetings!
Your password is:
$temp_pass
Your friends at: $website_name !
MESSAGE;
$headers = 'From: ' . $this->email_from . "\r\n" . 'Reply-To: ' . $this->email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion ();
mail ( $email_addy, $this->email_subject, $message, $headers );
}
Any ideas why Gmail just deletes the email? I thought that the message body text might be too small so I even added to the message with no different results...

PHP from field when sending mail()

I'm using PHP's mail() function and noticing that my mail is being shown from being sent by 'My Website' in my inbox, but when I click on the actual email it shows it being sent from mywebsite#sitename.localdomain.
Ideally I'd like to have it say being sent from 'My Website', but the reply email being 'no-reply#mywebsite.com', and not to have it say anything about #sitename.localdomain.
$to = trim(strtolower($_POST['to']));
$from = trim($_POST['from']);
$message = trim($_POST['message']);
$subject = $from . ' has shared a link with you';
$headers = 'From: My Website' . "\r\n" .
'Reply-To:' . $to . "\r\n" .
'X-Mailer: PHP/';
mail($to, $subject, $message, $headers);
Is this an issue that I need to fix in Apache, or can I modify the headers within PHP?
Try this:
$to = trim(strtolower($_POST['to']));
$from = trim($_POST['from']);
$message = trim($_POST['message']);
$subject = $from . ' has shared a link with you';
$headers = 'From: My Website <no-reply#mywebsite.com>' . "\r\n" . // <- change your email here
'Reply-To:' . $to . "\r\n" .
'X-Mailer: PHP/';
mail($to, $subject, $message, $headers);
The Question and Answer #1 contains a serious security vulnerability -
$to = trim(strtolower($_POST['to']));
Will allow an attacker to use your website to email arbitrary spam and your site will be blocked from most search engines.
See
https://www.owasp.org/index.php/Top_10_2010-A1
My recommendation is to
Sanitize the to and from fields
Never ever ever copy the message in the post to the output unless carefully sanitized.

Categories