Welcome Guest, Not a member yet? Register   Sign In
email library error in sending email function
#1

[eluser]Yogesh[/eluser]
I am using the email library and helper of CodeIgniter
but it is giving me notice like
A PHP Error was encountered

Severity: Notice

Message: Undefined index: Subject

Filename: libraries/Email.php

Line Number: 937

How i can avoid this Notice


here's code
in constructor of the controller I have added
$this->load->library('email');
$this->load->helper('email');


I don't is it needed to add both helper and library of email

and just to test the email is sending out or not
I used the folloing function
function test_mail()
{
$receiver_email_address = "[email protected]";
$category_name = "Assigned to admin";
$sender_email_address = "admin@admin.com";
$sender_name = 'Admin';
$reply_email_address = 'admin@admin.com';
$reply_name = 'Admin';
$subject = "Subscription Notification: New Question is posted in ".$category_name;
$message = $this->input->post('question');
$this->email->from($sender_email_address, $sender_name); // email address of the sender
$this->email->reply_to($reply_email_address, $reply_name); // email address for the reply
$this->email->to($receiver_email_address); // email address of the receiver
$this->email->subject("Subscription Notification: New Question is posted in ".$category_name); // subject line for the email
$this->email->message($message); // message content for email
$this->email->send(); // This function will send the email
if(!$this->email->send())
{
echo "<h1>Failed</h1>";
}
else
{
echo "<h1>Great</h1>";
}
exit;
}


email is get sending out but then why that Notice is coming
Thanks in Advance !!!
#2

[eluser]sophistry[/eluser]
you are sending twice. that might be part of the problem. take out the extra this email send line.
#3

[eluser]Edmundas KondraĊĦovas[/eluser]
You need to load email helper only when you want to check if the email address is valid (using this function: valid_email()).
#4

[eluser]Yogesh[/eluser]
[quote author="sophistry" date="1233787275"]you are sending twice. that might be part of the problem. take out the extra this email send line.[/quote]
Thanks a lot !
I had made a silly mistake Tongue
Thanks now it's working properly Smile




Theme © iAndrew 2016 - Forum software by © MyBB