|
#1
|
|||
|
|||
|
I've been pulling my hair out for a whole day. The same code that I have on another server won't work here. If there are some examples, that'd be really sweet.
|
|
#2
|
|||
|
|||
|
What error are you getting?
|
|
#3
|
||||
|
||||
|
And can you post your code? Does your other server use PHP5?
__________________
Follow me on Twitter! http://twitter.com/mrw |
|
#4
|
|||
|
|||
|
I have PHPmailer working. I would need to edit my script to remove private info before posting, and I don't have time to do that today. I display the form and handle it all in the same page. For mailing I specify smtp with authentication turned on. That works with an email account I created for my primary domain (with a shared non-reseller account) using cPanel.
Make sure you have the correct path for class.phpmailer.php. Also make sure you have $MailServer = mail.yourdomain.com and not smtp.yourdomain.com. When you move a script from one server to another, it's often the little things. Good luck. When I get a chance to edit my script, I'll post it. |
|
#5
|
|||
|
|||
|
I was able to get my script working if I change to SMTP server to mail.<mydomain>.com. I was trying to get to an external SMTP server, which doesn't seem to work. Maybe its a firewall issue at hostgator.
|
|
#6
|
|||
|
|||
|
Glad you found a way to get your script working. I did a test and I was able to use an external SMTP server. Specifically, I was able to use a gmail account by following the example script for gmail that is included in the PHPmailer documentation. The key lines seem to be:
$mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; Here's the entire script from PHPMailer_v2.0.0/docs/use_gmail.txt: <?php // example on using PHPMailer with GMAIL include("class.phpmailer.php"); include("class.smtp.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port $mail->Username = "yourname@gmail.com"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->From = "replyto@yourdomain.com"; $mail->FromName = "Webmaster"; $mail->Subject = "This is the subject"; $mail->Body = "Hi,<br>This is the HTML BODY<br>"; //HTML Body $mail->AltBody = "This is the body when user views in plain text format"; //Text Body $mail->WordWrap = 50; // set word wrap $mail->AddAddress("username@domain.com","First Last"); $mail->AddReplyTo("replyto@yourdomain.com","Webmaster" ); $mail->AddAttachment("/path/to/file.zip"); // attachment $mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment $mail->IsHTML(true); // send as HTML if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?> |
|
#7
|
|||
|
|||
|
Sweet! This will come in handy as I'm using google apps for email.
|
|
#8
|
|||
|
|||
|
Mail(): Return True but cannot send
Dear Friends, I have a script in my website for sending feedback. It returns TRUE for mail() but it can't send email to receiver at all. Why? I have joomla nd drupal in my host but they work good and send emails successfully. ----------------------------------- My script is as following: $to = "admin@domain.org"; $sender = $_POST['email']; $headers = 'From:'.$sender."\r\n"; $headers .= 'MIME-Version: 1.0'."\n"; $headers .= 'Content-type: text/HTML; charset=utf-8'."\r\n"; $body = "<html><body style='font-family: Tahoma;'>".htmlspecialchars(nl2br($_POST['msg']))."<br><font color='#0000FF'>".$_POST['email']."</font></body></html>"; $send=mail($to, "WadiOnline News (Feedback) > ".$subject, $body, $headers); if($send){ echo 'Thanks for your feedback!'; } else { echo 'An Error happened in sending.'; } Waiting for your ehlp.
|
|
#9
|
||||
|
||||
|
Rowshan-- please don't post more than once. I answered in the other thread.
__________________
Follow me on Twitter! http://twitter.com/mrw |
|
#10
|
||||
|
||||
|
Particularly by digging up an old thread that's about another app.
__________________
Hosting term analogies, revised and improved (?) |
|
#11
|
||||
|
||||
|
Yes, it occurs to me I should have answered it here and complained there!
__________________
Follow me on Twitter! http://twitter.com/mrw |
|
#12
|
||||
|
||||
|
Nah, better here--the original post was, after all, off-topic itself but I thought it would be piling on to point out that that made digging it up to double-post about another app even worse.
__________________
Hosting term analogies, revised and improved (?) |
|
#13
|
|||
|
|||
|
Quote:
but when I try to execute it, I'm getting the error Mailer Error: SMTP Error: Could not connect to SMTP host. Can anyone give any idea how do I debug the code. Also is there anyway to make sure port 465 is open for my account? |
|
#14
|
||||
|
||||
|
Probably would have been better to start a new thread rather than reopen a nearly 3 year old thread. The poster of the code you posted hasn't posted in a couple of years.
Anyway, it could well be that the port is closed outgoing on the server but the only way to know for sure is to open a ticket with support and ask them if it is open and/or if it can be opened outgoing. |
|
#15
|
|||
|
|||
|
Quote:
ok will contact support and update here |
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
|
|
All times are GMT -5. The time now is 03:17 AM.









