Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Lets go to the Point,
I hava a form like this
exhibition.php
<?php
include("email_class.php");
if(isset($_POST[SAVE])){
$email = $_POST[EMAIL];
$company = $_POST[COMPANY];
$gender = $_POST[GENDER];
$buyer = $_POST[BUYER];
$discussion = $_POST[DISCUSSION];
$class = new email_class();
$class->notifikasi($discussion);
}//end if
?>
And the code include file like this
email_class.php
<?php
class email_class{
function notifikasi($discussion){
if($discussion == "DISCUSSION"){
$to = $email;
$subjek = "Thanks for visiting us at Gulfood exhibition, Dubai";
$message = "<html>
<head>
<title>Exibithion Email</title>
</head>
<body>
bla blaa";
$message.= "Dear <b> ".$gender." ".$buyer."</b><br><br>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: **** Group <export#***>' . "\r\n";
echo $message;
}//end if
}//end function
}//end of class
?>
Ok, echo HTML mail is Succees. anything is running well, only the variabel from exhibition.php cant pass to the email_class.php.
Can anyone Fix my Problem?
Pass the values as arguments to notifikasi.
<?php
include("email_class.php");
if(isset($_POST[SAVE])){
$class = new email_class();
$class->notifikasi($_POST[EMAIL], $_POST[COMPANY], $_POST[GENDER], $_POST[BUYER], $_POST[DISCUSSION])
}//end if
?>
class
class email_class{
function notifikasi($email, $company, $gender, $buyer, $discussion){
if($discussion == "DISCUSSION"){
/** ... **/
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am currently using Swiftmailer to send my emails. Everything works fine it is sending the emails however the emails are not showing the Logo I have put in. Here is the code:
require_once 'vendor/autoload.php';
require_once 'config/constants.php';
// Create the Transport
$transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl'))
->setUsername(EMAIL)
->setPassword(PASSWORD);
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
function sendVerificationEmail($userEmail, $token){
global $mailer;
$body = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Verify Email</title>
</head>
<body>
<div class="not-verified-container">
<img src="logo.svg" class="mazaw-logo-not-verified">
<div class="container-without-logo">
<div class="not-verified-texts">
<h2>Account Verification</h2>
</div>
</div>
</div>
</body>
</html>';
// Create a message
$message = (new Swift_Message('Account Verification'))
->setFrom(EMAIL)
->setTo($userEmail)
->setBody($body, 'text/html');
// Send the message
$result = $mailer->send($message);
}
I would be very very thankful if someone could take a look and see what I have done wrong.
Thank you!
Embedding should work fine
<?php
$message = new Swift_Message('Your subject');
$message->setBody(
'<html>' .
' <body>' .
' <img src="' . $message->embed(Swift_Image::fromPath('image.png')) . '" />' .
' </body>' .
'</html>',
'text/html'
);
?>
You need to include the logo image in the email as an attachment. Not sure how thats done in Swiftmailer but when I googled it there are numerous examples including this one from here in StackOverflow.
Swiftmailer Attachments
$uploadedFileName = CUploadedFile::getInstance($model,'career_resume');
$uploadedFileName = $uploadedFile->tempName; // will be something like 'myfile.jpg'
$swiftAttachment = Swift_Attachment::fromPath($uploadedFileName);
$message->attach($swiftAttachment);
Also Google how to embed an image in Swiftmailer.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have this code which outputs a QR code:
<?php
include(JPATH_LIBRARIES . '/phpqrcode/qrlib.php');
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('Soci', 'Nom', 'Cognoms', 'eCorreu')))
->from($db->quoteName('#__rsform_socis'))
->where($db->quoteName('username') . ' = '. $db->quote($user->username));
$db->setQuery($query);
$codeContents = $db->loadObjectList();
$data .= "Soci Nº: {$codeContents[0]->Soci}\n ";
$data .= "Nom: {$codeContents[0]->Nom} ";
$data .= "{$codeContents[0]->Cognoms}\n";
$data .= "e-correu: {$codeContents[0]->eCorreu}";
$tempDir = JPATH_SITE . '/images/';
$fileName = 'qr_'.md5($data).'.png';
$pngAbsoluteFilePath = $tempDir.$fileName;
$urlRelativeFilePath = JUri::root() .'images/' . $fileName;
if (!file_exists($pngAbsoluteFilePath)) {
QRcode::png($data, $pngAbsoluteFilePath);
}
echo '<img src="'.$urlRelativeFilePath.'" />';
echo '<br>Descarrega el carnet';
?>
However, when the user reloads the page or goes back to it it gives an error:
Notice: Undefined variable: data in /home/u916662558/public_html/plugins/system/sourcerer/helper.php(632) : runtime-created function on line 3
I guess it has something to do with the fact that the code is already in the file system. How can I get rid of it (the error)?
Thanks,
Dani
You haven't defined $data at the point you try to self-concatenate:
$data .= "Soci Nº: {$codeContents[0]->Soci}\n ";
This is the function equivalent of
$data = $data . "Soci ...";
^^^^----not defined yet
Add a var initialization first:
$data = ''; //
$data .= etc...
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm very new to php and I'm trying to create an unordered list from a text file. I read in the text file "oscars.txt" and then create the unordered list. I believe my logic is correct, but when I host the page, I cannot get anything to show up. It says it cannot load my page. This leads me to believe that something in my syntax is incorrect. Does anyone have any ideas what I have done incorrectly here and how I can go about resolving it? Thanks for any help. Here is what I have done so far:
<html>
<head>
<title>Un-ordered list</title>
</head>
<body>
<?php
$file = fopen("oscars.txt", "r")
$i=0;
while(!feof($myfile)){
$members[]= fgets($file);
}
fclose($file);
$arrlength =count($members)
$title = True;
for($i=0;$i<($arrlength);$i++){
if($title=True){
echo "<h2"> . $members[$i] . "<h2><ul>";
$title = False;
}
if(trim($members[$i])==''){
echo "</ul><h2>" . $members[{$i+1] . "</h2><ul>";
$i++;
} else {
echo "<li>" . $members[$i] . "</li>" ;
}
}
?>
</body>
</html>
There are quite a few things wrong with the code.
A missing semi-colon in $file = fopen("oscars.txt", "r")
Calling the wrong file while(!feof($myfile)){ it should be $file
Another missing semi-colon for $arrlength =count($members)
A misplaced quote in echo "<h2"> . $members[$i] . "<h2><ul>";
Plus, a brace inside $members[{$i+1]
Reworked:
<html>
<head>
<title>Un-ordered list</title>
</head>
<body>
<?php
$file = fopen("oscars.txt", "r");
$i=0;
while(!feof($file)){
$members[]= fgets($file);
}
fclose($file);
$arrlength =count($members);
$title = True;
for($i=0;$i<($arrlength);$i++){
if($title=True){
echo "<h2>" . $members[$i] . "<h2><ul>";
$title = False;
}
if(trim($members[$i])==''){
echo "</ul><h2>" . $members[$i+1] . "</h2><ul>";
$i++;
} else {
echo "<li>" . $members[$i] . "</li>" ;
}
}
?>
</body>
</html>
Add/enable error reporting to the top of your file(s) which will help during production testing.
error_reporting(E_ALL);
ini_set('display_errors', 1);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to render a php file and then return it as html to send in an email, how would I go about doing this? Here is an example of the code that I'm using:
public function setPHP($php)
{
ob_start();
$phpsend = ( include $php );
$this->html = (string) ob_get_contents();
ob_end_clean();
}
Here is how I'm calling the function.
$php = file_get_contents( NHM_PLUGIN_DIR . 'assets/templates/newhomesguide.php' );
$css = file_get_contents( NHM_PLUGIN_DIR . 'assets/css/email_template.css' );
$cssToInlineStyles->setPHP($php);
$cssToInlineStyles->setCSS($css);
I'm trying to modify CSSToInlineStyles by Tijs Verkoyen, which inlines css with html, I'm just trying do do the same but with a php file that has functionality.
I think you're pretty close. This is how I would do it. The evaluated file will be in $this->html like you want and it will immediately be sent to the output stream after being evaluated.
public function setPHP($php)
{
if(!file_exists($php)) // Some error handling here maybe?
die('File ' . $php . ' DNE');
// Eval the $php file and store it in a variable
ob_start();
include $php;
$this->html = ob_get_clean();
// Send the evaluated file to the output stream
echo $this->html;
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
When i fetch email using imap in php, i get email body content but i m not able to extract inline images pasted and not attached in the email body.
Search for image in the body of the email content.
Suppose your email body is $body then you could get the image url using preg_match.
Use this preg_match expression to get the image source.
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $body, $matches);
hey i think i got a solution
<?php
$hostname = '{myserver/pop3/novalidate-cert}INBOX';
$username = 'username';
$password = 'password';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Tiriyo: ' . imap_last_error());
$msgno = 0; //message id
$no_of_occurences = 0;
$intStatic = 2;//to initialize the mail body section
$decode = imap_fetchbody($mbox, $msgno , "");
$no_of_occurences = substr_count($decode,"Content-Transfer-Encoding: base64");//to get the no of images
if($no_of_occurences > 0){
for($i = 0; $i < $no_of_occurences; $i++){
$strChange = strval($intStatic+$i);
$decode = imap_fetchbody($mbox, $msgno , $strChange);//to get the base64 encoded string for the image
$data = base64_decode($decode);
$fName = time()."_".$strChange . '.gif';
$file = $fName;
$success = file_put_contents($file, $data); //creates the physical image
}
}
imap_close($inbox);
?>