PHPMailer script working Hostinger not on fatcow - php

I have a PHPMailer script. It's working fine on my Hostinger account, but when I move it over to my company's FatCow server it stops working.
Any help would be much appreciated!
The code is:
$email = new PHPMailer();
$email->IsSendmail();
$email->From = "stuart#ubrew.cc";
$email->FromName = "Stuart";
$email->Subject = "Subject...";
$email->Body = "text"; // BODY TEXT HERE
$email->AddAddress("$customeremail");
$email->AddAttachment($certificateName, 'GiftCertificate.pdf');
if (!$email->Send()) {
$message = $email->ErrorInfo;
mail('sewelly#gmail.com', 'MAILER ERROR', $message);
}

Related

Using PHPMailer send attachment file in PHP

I currently using PHPMailer to sending mail with attachment file in localhost and also in my server.
The problem I have is the attachment file does not receive in email when execute in server. But in other side, the attachment file receive perfectly when I execute on localhost.
Here is my simple code:
$email = new PHPMailer();
$email->From = 'william#msmedia.com.sg';
$email->FromName = 'John';
$email->Subject = 'Message Subject';
$email->Body = 'test';
$email->AddAddress( 'william#msmedia.com.sg' );
$file_to_attach = $_FILES["cv"]["tmp_name"];
$email->AddAttachment( $file_to_attach , $_FILES["cv"]["name"]);
return $email->Send();
Can anyone able to correct my mistake..?

PHPMailer emails not sending but there are no errors

I am using PHPMailer and using this PHP Code to send emails:
$email = new PHPMailer();
while($result2=mysql_fetch_array($rs2))
{
$email->AddAttachment( $result2["attachment"] , basename($result2["attachment"]) );
}
$email->From = 'Integra Digital';
$email->FromName = $result["emailfrom"];
$email->Subject = $result["subject"];
$email->Body = $result["message"];
$email->AddAddress($result["emailto"]);
$email->IsHTML(true);
if(!$email->Send())
{
echo "<strong>Mailer Error: </strong>" . $email->ErrorInfo;
}
else
{
echo '<strong>Email sent to: </strong>' .implode(',',$emails_list). '<br/ >';
}
$result["emailto"] is equal to a valid email address but i am not receiving the emails
any ideas?
looks like it wanted the AddAttachment part after everything else and just before the Send function

PHP Mailer Error: Mailer Error - must provide at least one recipient email address

I'm having and an issue with php mailer script. Using mamp the script works, but on the server I get an error (I've omitted sensitive info).
"Invalid address: [valid email] Mailer Error: You must
provide at least one recipient email address."
Heres my code:
require_once("includes/phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.emailsrvr.com";
$mail->SMTPDebug = 2;
$mail->Port = 25;
$mail->Username = "test#test.com";
$mail->Password = "test";
$mail->Subject = "Subject";
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->AddReplyTo($_POST['email'], $_POST['name']);
$address = "test#test.com";
$mail->AddAddress($address, "name");
$body = "<p>test</p>";
$mail->MsgHTML($body);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
If it helps, I am using the rackspace email apps.
Im not very savy with php or server setups unfortunately so if anyone can help that would be great!
Just change this line:
$address = "[valid email]";
to something like:
$address = "test#test.te";
or to your own email, so you can test better, and it will work.
It's just stating that '[valid email]' is not actually a "valid email".
So i had no luck here, but I now know the issue stems from server mail settings rather then the script.
In the end I just went to using postmark.
I face this issue when my class name and my function name is same. Than i change the name of the function and it was resolved. Hope it will help anyone.

PHPMailer not sending mail

I'm trying to send an order confirmation and also notify the seller about a user purchase. However, PHPMailer only sends the first email. Here's quick and dirty:
$bodytext = 'Mail.';
$email = new PHPMailer();
$email->From = 'mail#mail.com';
$email->FromName = 'Sender';
$email->Subject = 'Subject';
$email->Body = $bodytext;
$email->AddAddress($_REQUEST['sahkoposti']);
$email->AddAttachment($path, 'kuitti'.$ordernumber.'.pdf');
return $email->Send();
?>
<?php
//send message to seller
$bodytext = 'Mail.';
$email = new PHPMailer();
$email->From = 'mail#mail.com';
$email->FromName = 'Sender';
$email->Subject = 'Tilaus vastaanotettu';
$email->Body = $bodytext;
$email->AddAddress("mail#mail.com");
$email->AddAttachment($path, 'kuitti'.$ordernumber.'.pdf');
return $email->Send();
?>
Is it even possible to send multiple emails from one script?
It is possible, however you're using return in the first statement, which will stop execution of the function. Remove the first return (just use $email->Send();) and it should work.
The second email does not get executed because you are returning right after sending the first email, you should change:
return $email->Send();
for this:
$email->Send();

php mailer Mailer Error: Language string failed to load: connect_host?

I keep getting this error..
below is my code:
<?php
ini_set("include_path", "phpmailer/");
require 'phpmailer/class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'smtp.gmail.com';
$mailer->Port='465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'mail#gmail.com'; // Change this to your gmail adress
$mailer->Password = '****'; // Change this to your gmail password
$mailer->From = 'maile#gmail.com'; // This HAVE TO be your gmail adress
$mailer->FromName = 'Belmer'; // This is the from name in the email, you can put anything you like here
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('another#ymail.com'); // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
Anyone knows this error? Your reply is greatly appreciated.
Got it! Thanks guys for viewing.
There's actually no problem with the code, it has to be some settings on my local server. My solutions is i uploaded the files to my live webserver and everything is working fine.

Categories