vatsal06 Posted May 29, 2009 Share Posted May 29, 2009 I have file by the name of forgot.php and am using the following code: <?php require_once "Mail.php"; $db=mysql_connect("$Sname","$Uname","$Pname"); mysql_select_db("$Dname",$db); if ($sub) { // send information to owner $sql="SELECT * FROM $Tname WHERE email='$imail'"; $result=mysql_query($sql); if ($myrow = mysql_fetch_array($result)) { $subject="$School alumni register"; $message="$School alumni, this is your username and password which you will need to change your details or to send e-mails to other member.\n\n Username: $myrow[username]\n\n Password: $myrow[password]"; $host = "mail.greatindian.org"; $username = "alumni"; $password = "pass888"; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($imail, $subject, $message,"From: $Mail"); ?> I am getting the error: Warning: Invalid argument supplied for foreach() in /usr/local/lib/php/Mail.php on line 123 Warning: Invalid argument supplied for foreach() in /usr/local/lib/php/Mail.php on line 151 I urgently need help! Link to comment https://forums.phpfreaks.com/topic/160119-help-with-mail-function/ Share on other sites More sharing options...
waynew Posted May 29, 2009 Share Posted May 29, 2009 Wait just a second while I log into your computer and open up Mail.php That's where the error is. Warning: Invalid argument supplied for foreach() in /usr/local/lib/php/Mail.php on line 151 Could you post the code from Mail.php here? You do know that the error is on line 151 don't you? Link to comment https://forums.phpfreaks.com/topic/160119-help-with-mail-function/#findComment-844782 Share on other sites More sharing options...
vatsal06 Posted May 29, 2009 Author Share Posted May 29, 2009 Actually I am trying to merge codes from 2 diiferent sources. My webhost has provided me a file mail.php with the following code: <?php require_once "Mail.php"; $from = "name Sender <[email protected]>"; $to = "name Recipient <[email protected]>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "mail.domainname.com"; $username = "user"; $password = "pwd"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> and I have a file Aedit.php which has the following code: <?php $db=mysql_connect("$Sname","$Uname","$Pname"); mysql_select_db("$Dname",$db); if ($sub) { // send information to owner $sql="SELECT * FROM $Tname WHERE email='$imail'"; $result=mysql_query($sql); if ($myrow = mysql_fetch_array($result)) { $subject="$School alumni register"; $message="$School alumni, this is your username and password which you will need to change your details or to send e-mails to other member.\n\n Username: $myrow[username]\n\n Password: $myrow[password]"; mail($imail, $subject, $message,"From: $Mail"); ?> Link to comment https://forums.phpfreaks.com/topic/160119-help-with-mail-function/#findComment-844788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.